From: Operating system: Ubuntu 10.04 AMD64 W/S PHP version: 5.3.3 Package: PDO related Bug Type: Bug Bug description:PDO treats backslashes in pgsql passwords as escape characters
Description: ------------ When using a password containing a backslash to connect to PostgreSQL database via PDO the driver appears to be treating the backslash as an escape charcter. The problem is not global to PDO since MySQL works as expected. It is not global to libpq since PearDB and the psql command line tool work as expected. Further explanation in the comments in the test script. Test script: --------------- $host = 'localhost'; $database = 'imix'; $username = 'imix'; // Password is |\/|ix3dUp /* Works for MySQL - Doesn't work for pgsql - wireshark shows |/x3edUp sent to server, error message shows password correctly */ $mysql_password = '|\/|ix3dUp'; /* Doesn't work for pg - |/x3edUp still sent to server - error message still shows password correctly - this is because \ is one of the two chars escaped in a single quoted string */ // $password = '|\\/|ix3dUp'; /* Works for pgsql, not for mysql - Error message on mysql attempt shows two backslashes Initial parse treats the first one as an escape, handing two to PDO - pgsql driver seems to interpret the first remaining one as an escape which really doesn't sound right ... */ $pgsql_password = '|\\\/|ix3dUp'; $mysql_connection = new PDO('mysql:host='.$host.';dbname='.$database, $username, $mysql_password); $pgsql_connection = new PDO('pgsql:host='.$host.';dbname='.$database, $username, $pgsql_password); Expected result: ---------------- I would expect the password as used for MySQL to work for both the engines. Actual result: -------------- Test script as it stands executes without error. -- Edit bug report at http://bugs.php.net/bug.php?id=53217&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53217&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53217&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53217&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53217&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53217&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53217&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53217&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53217&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53217&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53217&r=support Expected behavior: http://bugs.php.net/fix.php?id=53217&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53217&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53217&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53217&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53217&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53217&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53217&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53217&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53217&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53217&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53217&r=mysqlcfg