From:             
Operating system: All
PHP version:      5.3.10
Package:          *Data Exchange functions
Bug Type:         Feature/Change Request
Bug description:Unserialize should handle incorrect or missing string-length

Description:
------------
A serializing string "foo" produces an intuitive result 's:3:"foo"' and
unserialize() properly decodes that back.

It would be useful, however, if the unserialize function could handle (even
if less efficiently) cases, where the string-length is missing or even
specified incorrectly. Currently any such mismatches result in empty output
from the function, even though `s:"foo"' or `s::"foo"' or even `s:4:"foo"'
is no harder to understand.

The feature would be of help to those of us, who need to a massive
search/replace in the dump of serialized objects.

Test script:
---------------
<?
$s1 = "s:7:\"1234567\"";
$s2 = "s:6:\"1234567\"";
$s3 = "s:8:\"1234567\"";
$s4 = "s::\"1234567\"";

print "S1: >" . unserialize($s1) . "<\n";
print "S2: >" . unserialize($s2) . "<\n";
print "S3: >" . unserialize($s3) . "<\n";
print "S4: >" . unserialize($s4) . "<\n";
?>


Expected result:
----------------
S1: >1234567<
S2: >1234567<
S3: >1234567<
S4: >1234567<


Actual result:
--------------
S1: >1234567<
S2: ><
S3: ><
S4: ><


-- 
Edit bug report at https://bugs.php.net/bug.php?id=61255&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61255&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61255&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61255&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61255&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61255&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61255&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61255&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61255&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61255&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61255&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61255&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61255&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61255&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61255&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61255&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61255&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61255&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61255&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61255&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61255&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61255&r=mysqlcfg

Reply via email to