Home » Database » DB » Bug #3748
postgres password does not escape spaces.
Details
| Submitted | 2005-03-08 21:46 UTC |
|---|---|
| From | phadley at village dot com |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 4.2.2 |
| OS | Linux/FreeBSD |
| Roadmaps | (Not assigned) |
Comments
[2005-03-08 21:46 UTC] phadley at village dot com
Description:
------------
In assembling the connections string from the dns
info, the addslashes function does not slash spaces. I
get around this with either str_replace or by placing
escaped single quote marks before and after.
Reproduce code:
---------------
lines 103-107 of pear/DB/pgsql.php v.1.65.2.3 as I've modified it.
The first and third variations work. The second one doesn't and the fourth one came with my package.
The second alternative (addslashes) was taken from the newer verson. The fourth line is what I have on my personal machine.
if (!empty($dsninfo['password'])) {
$connstr .= ' password=' . str_replace(' ','\ ',$dsninfo['password']);
# $connstr .= ' password=' . addslashes($dsninfo['password']);
# $connstr .= ' password=\'' . $dsninfo['password'].'\'';
# $connstr .= ' password=' . $dsninfo['password'];
Expected result:
----------------
I expect to be able to connect to the database
even if my password has a space.
Actual result:
--------------
It doesn't connect because it thinks the password is
only the first word in the phrase.