mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Update connection-parameters.js
The current connection url handling fails when the password contains encoded special characters: After the encodeURI, the special characters from the password are double encoded, and the password is rejected by postgres. Proposed fix handles one level of double encoding, and while it might break compatibility with passwords like "asdfg%77fgh" (which would've been escaped to asdfg%2577fgh before this patch), I strongly feel that maintaining backwards compatibility is in this case less important than following standards and discouraging bad coding practices.
This commit is contained in:
parent
b33c266734
commit
c666b20287
@ -17,7 +17,8 @@ var parse = function(str) {
|
||||
return { host: str };
|
||||
}
|
||||
// url parse expects spaces encoded as %20
|
||||
str = encodeURI(str);
|
||||
// however, we don't want to double-encode
|
||||
str = encodeURI(str).replace(/\%25/g, "%");
|
||||
var result = url.parse(str);
|
||||
var config = {};
|
||||
config.host = result.hostname;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user