diff --git a/lib/connection_config.js b/lib/connection_config.js index ec52051625e..a18b30b3301 100644 --- a/lib/connection_config.js +++ b/lib/connection_config.js @@ -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 { diff --git a/test/unit/connection/test-connection_config.js b/test/unit/connection/test-connection_config.js index 0e1c0b1ca66..7222f77db32 100644 --- a/test/unit/connection/test-connection_config.js +++ b/test/unit/connection/test-connection_config.js @@ -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:', );