#48840 [Bgs]: serialized object: data loss in some use case
| From: | schindler dot andor at pokhalo dot hu | Date: | Tue, 07 Jul 2009 21:08:25 +0000 |
| Subject: | #48840 [Bgs]: serialized object: data loss in some use case | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139444@lists.php.net to get a copy of this message | ||
ID: 48840
User updated by: schindler dot andor at pokhalo dot hu
Reported By: schindler dot andor at pokhalo dot hu
Status: Bogus
Bug Type: Class/Object related
Operating System: *
PHP Version: 5.2.10
New Comment:
And what can i do? base64_encode()/base64_decode() is ridiculous for
this example. I can use pg_escape_bytea() too, but the result of
serialized anything shouldn't to be a binary data.
I think a serialization method mustn't use special characters, so i
think, it's a design bug.
Previous Comments:
------------------------------------------------------------------------
[2009-07-07 20:41:27] jani@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
------------------------------------------------------------------------
[2009-07-07 19:45:36] schindler dot andor at pokhalo dot hu
Description:
------------
If i serialize a PHP object, then become some \0 characters in
property's field name. This cause some problems, where others using
char* instead of smart_str.
Example: If i try escape a serialized object's string with
pg_escape_string() then i give a truncated string, because the
PQescapeStringConn()/PQescapeString() terminate the processing at the \0
character.
Reproduce code:
---------------
class aClass
{
private $a;
public function __construct()
{
$this->a = 1;
}
}
$obj = new aClass();
$str = serialize($obj);
// gives: 'O:6:"aClass":1:{s:9:"#aClass#a";i:1;}'
// (i marked \0's places with a #)
echo $str;
$conn = pg_connect('...');
// gives: 'O:6:"aClass":1:{s:9:"'
echo pg_escape_string($conn, $str);
Expected result:
----------------
I think it would be better, if the serialize don't give \0. I think,
it's can not be problem, if serialize uses # or anything instead of \0.
Actual result:
--------------
See code.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48840&edit=1