序列化字符串中的偏移错误没有意义

时间:2016-11-11 12:00:21

标签: php mysql serialization offset

因此,当我尝试在PHP中序列化时,此字符串显示为false。

我使用了2个在线序列化网站。

第一次测试返回正常。这是这个网站:http://blog.tanist.co.uk/files/unserialize/

其他网站显示了真正的问题。还是吗?我糊涂了。这是这个网站:https://www.functions-online.com/unserialize.html

我得到的第一个错误是“偏移1095的7441字节” 这恰好位于s:6:"filter";中的“t”(位于代码段的第12行)

我认为这意味着它出于某种原因将字符数读为4? 我尝试替换所有字符,包括引号,以确保它们不是代表多个字节的字符的奇数版本。那没用。但是,如果我将“过滤器”更改为“过滤”,那么它就可以了。它移动到下一个偏移错误。

我在序列化之前尝试了很多关于字符串的转换,我在网上找到了解决方案。

utf8_encode

base64_decode

他们都没有帮助。

这是字符串。 (直接从具有utf8_general_ci排序规则的mysql表中复制)

a:13:{i:3;a:4:{s:5:"title";s:16:"Regional Offices";s:4:"text";s:1025:"<p>
<a href="/who-we-are/structure/conferences/alaska/">Alaska Conference of the Evangelical Covenant Church</a><br />
<a href="/who-we-are/structure/conferences/canada/">Evangelical Covenant Church of Canada</a><br />
<a href="/who-we-are/structure/conferences/central/">Central Conference</a><br />
<a href="/who-we-are/structure/conferences/east-coast/">East Coast Conference</a><br />
<a href="/who-we-are/structure/conferences/great-lakes/">Great Lakes Conference</a><br />
<a href="/who-we-are/structure/conferences/midsouth/">Midsouth Conference</a><br />
<a href="/who-we-are/structure/conferences/midwest/">Midwest Conference</a><br />
<a href="/who-we-are/structure/conferences/northwest/">Northwest Conference</a><br />
<a href="/who-we-are/structure/conferences/north-pacific/">Pacific Northwest Conference</a><br />
<a href="/who-we-are/structure/conferences/pacific-southwest/">Pacific Southwest Conference</a><br />
<a href="/who-we-are/structure/conferences/southeast/">Southeast Conference</a></p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:4;a:4:{s:5:"title";s:9:"Translate";s:4:"text";s:614:"<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en',
    gaTrack: true,
    gaId: 'UA-2683611-22',
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE
  }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<p><span style="font-size:10px; line-height:11px"><br /><strong>Disclaimer</strong>: This translation may not be completely accurate as it is generated by a computer.</span><br />&nbsp;</p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:5;a:4:{s:5:"title";s:10:"Contact Us";s:4:"text";s:920:"<p>The Evangelical Covenant Church<br />
8303 West Higgins Road<br />
Chicago, Illinois 60631<br />
<a href="http://www.covchurch.org/who-we-are/help/contact-us/">Contact us</a></p>

<h3>Stay Connected</h3>

<p><a href="http://www.facebook.com/covchurch" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-facebook.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.twitter.com/cov_church" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-twitter.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.instagram.com/cov_church" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-instagram.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.covchurch.tv" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-dottv.png" width="35" /></a>&nbsp;&nbsp;<a href="http://www.covchurch.org/subscribe" target="_blank"><img src="/wp-content/uploads/2013/07/ecc-rss.png" width="35" /></a></p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:6;a:4:{s:5:"title";s:21:"Affiliated Ministries";s:4:"text";s:1093:"<p><a href="/affiliated/camps-retreat-center/">Camps and Retreat Centers</a><br />
<a href="http://www.chet.org/" target="_blank" title="CHET">CHET: Hispanic Theological Studies</a><br />
<a href="http://covcare.org/" target="_blank" title="CIC">Covenant Initiatives for Care</a><br />
<a href="http://www.covenantbenevolence.org/" target="_blank">Covenant Ministries of Benevolence</a><br />
<a href="/benefits/pension/">Covenant Pension Plan</a><br />
<a href="http://www.covenantretirement.org/" target="_blank">Covenant Retirement Communities</a><br />
<a href="http://www.covenanttrust.com/" target="_blank">Covenant Trust Company</a><br />
<a href="/affiliated/health-care-residences/">Health Care and Enabling Residences</a><br />
<a href="/ncp/">National Covenant Properties</a><br />
<a href="http://www.northpark.edu/Seminary.aspx" title="NPTS" target="_blank">North Park Theological Seminary</a><br />
<a href="http://www.northpark.edu" target="_blank" title="NPU">North Park University</a><br />
<a href="http://paulcarlson.org/">Paul Carlson Partnership</a><br />
</p>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:7;a:3:{s:5:"title";s:0:"";s:4:"text";s:128:"<br /><a href="http://covbooks.com" target="_blank"><img src="/wp-content/uploads/2012/01/covbooks-banner.jpg" border="0" /></a>";s:6:"filter";b:0;}i:8;a:3:{s:5:"title";s:9:"User Poll";s:4:"text";s:244:"<iframe style='width:245px; height:367px; overflow-x:hidden;' frameborder='0' name='proprofs' id='proprofs' src='http://www.proprofs.com/polls/widget/?title=whats-the-length-of-video-that-you-least-likely-to-load&theme=grey&width=237'></iframe>";s:6:"filter";b:0;}i:10;a:4:{s:5:"title";s:20:"Search CovChurch.org";s:4:"text";s:463:"<form action="http://www.covchurch.org/search-covchurch/" id="cse-search-box"><div><input type="hidden" name="cx" value="000453154239674603993:lmfbvipbnwq" /><input type="hidden" name="cof" value="FORID:11" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="24" /><input type="submit" name="sa" value="Search" /></div></form><script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:11;a:4:{s:5:"title";s:20:"Search CovChurch.org";s:4:"text";s:505:"<form action="http://www.covchurch.org/search-covchurch/" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="000453154239674603993:lmfbvipbnwq" />
    <input type="hidden" name="cof" value="FORID:11" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="18" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:12;a:4:{s:5:"title";s:0:"";s:4:"text";s:128:"<br /><a href="http://covbooks.com" target="_blank"><img src="/wp-content/uploads/2012/01/covbooks-banner.jpg" border="0" /></a>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:13;a:4:{s:5:"title";s:0:"";s:4:"text";s:128:"<br /><a href="http://covbooks.com" target="_blank"><img src="/wp-content/uploads/2012/01/covbooks-banner.jpg" border="0" /></a>";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:14;a:4:{s:5:"title";s:0:"";s:4:"text";s:424:"<a class="twitter-timeline" href="https://twitter.com/Cov_Church" data-widget-id="347782163544031232">Tweets by @Cov_Church</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
";s:6:"filter";b:0;s:5:"class";s:1:"S";}i:15;a:4:{s:5:"title";s:9:"Translate";s:4:"text";s:678:"<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, multilanguagePage: true, gaTrack: true, gaId: 'UA-2683611-22'}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<div style="margin-top: -15px;"><span style="font-size: 10px; line-height: 11px;">
<strong>Disclaimer</strong>: This translation may not be completely accurate as it is generated by a computer.</span>
</div>";s:6:"filter";b:0;s:5:"class";s:1:"S";}s:12:"_multiwidget";i:1;}

1 个答案:

答案 0 :(得分:1)

Error at offset 1095 of 7441 bytes实际上是正确的。它并不意味着你认为它意味着什么。

从偏移62处开始。在此观察s:1025:"开始一个从偏移70开始的字符串,而据称的长度为1025,这意味着该字符串的结束引用应为抵消1095(70 + 1025)......但事实并非如此。

错误是&#34; at&#34;在某种意义上偏移1095,即唯一可能的有效值" ...并且那不是那里找到的。它实际上早于11个字节,偏移量为1084.因此,错误是非常正确的,虽然乍一看有点违反直觉。

这是-11字节的错误,并且奇怪/方便/不太令人惊讶,您会发现您的字符串中有11个换行符,这正好解释了\r\n具有的差异仅替换为\r或仅\n可能仍然可以正确显示但不正确。

如何通过这种方式,您需要回溯调查,但错误是正确的;您的序列化值已损坏/损坏/操作不当,无法再解码。