Skip to content

Commit

Permalink
fix: add decodeuricomponent to parse uri encoded special characters i…
Browse files Browse the repository at this point in the history
…n host, username, password and datbase keys
  • Loading branch information
samarpanB committed Nov 14, 2023
1 parent 1aec4fd commit 9c20fbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/connection_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ class ConnectionConfig {
static parseUrl(url) {
const parsedUrl = new URL(url);
const options = {
host: parsedUrl.hostname,
host: decodeURIComponent(parsedUrl.hostname),
port: parseInt(parsedUrl.port, 10),
database: parsedUrl.pathname.slice(1),
user: parsedUrl.username,
password: parsedUrl.password
database: decodeURIComponent(parsedUrl.pathname.slice(1)),
user: decodeURIComponent(parsedUrl.username),
password: decodeURIComponent(parsedUrl.password),
};
parsedUrl.searchParams.forEach((value, key) => {
try {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/connection/test-connection_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ assert.doesNotThrow(() => {

assert.strictEqual(
ConnectionConfig.parseUrl(
String.raw`fml://test:pass!@$%^&*()\word:@www.example.com/database`
String.raw`fml://test:pass!%40%24%25%5E%26*()word%3A@www.example.com/database`,
).password,
'pass!%40$%%5E&*()%5Cword%3A'
'pass!@$%^&*()word:',
);

0 comments on commit 9c20fbe

Please sign in to comment.