ID:               37838
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jona at oismail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         PostgreSQL related
 Operating System: Windows 2000
 PHP Version:      5.1.4
 New Comment:

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

To encode binary characters such as \0 you need to use to 
pg_escape_bytea() function.


Previous Comments:
------------------------------------------------------------------------

[2006-06-18 16:21:24] jona at oismail dot com

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:"


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37838&edit=1

Reply via email to