Bug #69362 [NEW]: PDO-pgsql fails to connect if password contains a leading single quote
| From: | jon dot dufresne at gmail dot com | Date: | Fri, 03 Apr 2015 00:44:24 +0000 |
| Subject: | Bug #69362 [NEW]: PDO-pgsql fails to connect if password contains a leading single quote | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191797@lists.php.net to get a copy of this message | ||
From: jon dot dufresne at gmail dot com
Operating system: Linux
PHP version: 5.5.23
Package: PDO PgSQL
Bug Type: Bug
Bug description:PDO-pgsql fails to connect if password contains a leading single quote
Description:
------------
If a PostgreSQL user's password contains a leading single quote
(apostrophe) PDO-pgsql is unable to connect to the database as the user.
The script fails with the message:
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[08006] [7] unterminated quoted string in connection info
string'
Test script:
---------------
#!/bin/bash
echo "Trailing quote"
psql postgres -c "DROP DATABASE IF EXISTS testphp"
psql postgres -c "DROP ROLE IF EXISTS testphp"
psql postgres -c "CREATE ROLE testphp PASSWORD 'asdf''' LOGIN"
psql postgres -c "CREATE DATABASE testphp OWNER testphp"
php -r "new PDO(\"pgsql:dbname=testphp\", \"testphp\",
\"asdf'\");"
echo "Leading quote"
psql postgres -c "DROP DATABASE IF EXISTS testphp"
psql postgres -c "DROP ROLE IF EXISTS testphp"
psql postgres -c "CREATE ROLE testphp PASSWORD '''asdf' LOGIN"
psql postgres -c "CREATE DATABASE testphp OWNER testphp"
php -r "new PDO(\"pgsql:dbname=testphp\", \"testphp\",
\"'asdf\");"
Expected result:
----------------
PHP can connect to the database no problem.
Output from script:
$ bash test.sh
Trailing quote
DROP DATABASE
DROP ROLE
CREATE ROLE
CREATE DATABASE
Leading quote
DROP DATABASE
DROP ROLE
CREATE ROLE
CREATE DATABASE
Actual result:
--------------
$ bash test.sh
Trailing quote
DROP DATABASE
DROP ROLE
CREATE ROLE
CREATE DATABASE
Leading quote
DROP DATABASE
DROP ROLE
CREATE ROLE
CREATE DATABASE
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[08006] [7] unterminated quoted string in connection info
string' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('pgsql:dbname=te...',
'testphp', ''asdf')
#1 {main}
thrown in Command line code on line 1
--
Edit bug report at https://bugs.php.net/bug.php?id=69362&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69362&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69362&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69362&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69362&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69362&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69362&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69362&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69362&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69362&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69362&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69362&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69362&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69362&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69362&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69362&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69362&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69362&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69362&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69362&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69362&r=mysqlcfg