brianc/node-postgres — Issue #57: No question mark allowed in password
Author: chowey
Created: 2011-10-18 02:49:27+00:00
State: open

There is an issue that causes question marks in passwords to be rejected from the connection string. e.g.:

var str = 'pg://joe:schmoe?1@example.local/local';
pg.connect(str, function (err, client) {});

will throw an error, because `url.parse(str)` returns:

{ protocol: 'pg:',
slashes: true,
host: 'joe',
hostname: 'joe',
href: 'pg://joe:schmoe?1@example.local/local',
search: '?1@example.local/local',
query: '?1@example.local/local',
pathname: '/:shmoe' }

which is clearly incorrect. I expected that if I `encodeURIComponent` the password, that `pg` would figure it all out for me. However, this would require we change `utils.js` from:

27 config.password = auth[1];

to:

27 config.password = decodeURIComponent(auth[1]);

I see no adverse response to this, since any password that would be changed by `decodeURIComponent` will already break the system (correct me if I'm wrong).

What are your thoughts?