简体   繁体   中英

offset error in serialized string doesn't make sense

So this string appears false when i try to serialize it in PHP.

I use 2 online serializing websites.

the first test returns fine. that is this site: http://blog.tanist.co.uk/files/unserialize/

the other website shows the real problem. or does it? I'm confused. this is this site : https://www.functions-online.com/unserialize.html

The first error I get is " offset 1095 of 7441 bytes " which is precisely at the "t" in s:6:"filter"; (located on line 12 in the snippet)

I assume it means it's reading the character count as 4 for some reason? i tried replace all characters, including the quotes to make sure they weren't some odd version of the character that represents multiple bytes. That didn't work. But if I changed "filter" to "filt" it worked. and it moved onto the next offset error.

I've tried many conversions on the string before serializing, solutions I found online.

utf8_encode

base64_decode

None of them helped.

here's the string. (copied straight from a mysql table with a collation of utf8_general_ci)

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;}

Error at offset 1095 of 7441 bytes is actually correct. It just doesn't mean quite what you think it means.

Start at offset 62. Observe here that s:1025:" begins a string that starts at offset 70 and allegedly has a length of 1025, which means the closing quote for that string should be at offset 1095 (70 + 1025)... but it is not.

The error is "at" offset 1095 in the sense that the only possible valid value there is " ... and that's not what is found there. It's actually 11 bytes earlier, at offset 1084. Hence, the error is quite right, though a bit counter-intuitive at first glance.

This is an error of -11 bytes, and curiously/conveniently/not-too-surprisingly, you'll find there are 11 line breaks in your string, which exactly explains the discrepancy if \\r\\n has been substituted with only \\r or only \\n which might still display correctly but is incorrect.

How it got that way, you'll need to backtrack to investigate, but the error is correct; you have a serialized value that has been corrupted/damaged/inappropriately manipulated and can no longer be decoded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM