Edit report at http://bugs.php.net/bug.php?id=53217&edit=1
ID: 53217 Updated by: [email protected] Reported by: bell at ctrlf5 dot co dot za Summary: PDO treats backslashes in pgsql passwords as escape characters -Status: Open +Status: Bogus Type: Bug Package: PDO related Operating System: Ubuntu 10.04 AMD64 W/S PHP Version: 5.3.3 Block user comment: N New Comment: This is due the libpq behavior. See http://www.postgresql.org/docs/8.1/static/libpq.html Previous Comments: ------------------------------------------------------------------------ [2010-11-01 08:04:30] bell at ctrlf5 dot co dot za 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 this bug report at http://bugs.php.net/bug.php?id=53217&edit=1
