|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-06-19 01:30 UTC] iliaa@php.net
[2006-06-19 13:28 UTC] jona at oismail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Description: ------------ It appears that pg_escape_string is not capable of escaping null characters (such as those found in a serialised object with private/protected member variables). The returned string is truncated when the null character (\0) is encountered and thus any data after the null character is lost. It appears that PostGreSQL has a problem with null characters, as even using addslashes() for escaping the null character the query executes but data after the null character is never inserted into the database. This behaviour is observed on Windows 2000 running PostGreSQL 8.0.3 and PHP 5.1.4 via IIS 5.0. Reproduce code: --------------- <?php class Test { private $privateVar; protected $protectedVar; public function __construct($private, $protected) { $this->privateVar = $private; $this->protectedVar = $protected; } } echo pg_escape_string(serialize(new Test("private variable", "protected variable") ) ); ?> Expected result: ---------------- properly escaped string that can be sent to the PostGreSQL backend Actual result: -------------- screen output: O:4:"Test":2:{s:16:"