#45244 [Bgs]: serialize() inserts NUL chars when serializing objects
ID: 45244
Updated by: yunosh@php.net
Reported By: bukaj at bukaj dot net
Status: Bogus
Bug Type: Strings related
Operating System: OS X, FreeBSD
PHP Version: 5.2.6
New Comment:
It also says "Returns a string containing a byte-stream representation
of value that can be stored anywhere."
You can't store it everywhere, because there are a lot of storage
systems that truncate data a NUL chars, e.g. databases.
Previous Comments:
------------------------------------------------------------------------
[2008-06-12 11:10:03] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
From the documentation: \"serialize - Generates a storable
representation of a value\" - storable, not \"displayable\" ot something
like that.
------------------------------------------------------------------------
[2008-06-12 09:47:41] bukaj at bukaj dot net
Description:
------------
This issue has been marked as closed in bug
#29865 but THE PROBLEM IS STILL PRESENT IN 5.2.6.
Serialize inserts NUL (ASCII 0) characters into output when serializing
objects. Serialize CAN'T produce output with unprintable chars - that's
the idea of serialize! This issue has been marked as resolved in bug
#29865 but IT IS NOT.
Reproduce code:
---------------
$ php -r 'class Foo { protected $bar = 1; } $v = new Foo; echo
serialize($v);' | hexdump
Expected result:
----------------
No unprintable chars in result of serialize!!!
Actual result:
--------------
0000000 4f 3a 33 3a 22 46 6f 6f 22 3a 31 3a 7b 73 3a 36
0000010 3a 22 00 2a 00 62 61 72 22 3b 69 3a 31 3b 7d
000001f
mark the two 00's at 0x12 and 0x14
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45244&edit=1
Thread (3 messages)