mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 13:37:28 +00:00
fix(mongodb): prevent double encoding of credentials in connection string
Fixes #15397
This commit is contained in:
parent
13bddce444
commit
4494bfee5e
1 changed files with 13 additions and 3 deletions
|
|
@ -316,9 +316,19 @@ async getConnection(sourceOptions: SourceOptions): Promise<any> {
|
|||
|
||||
const finalHosts = hostsList.join(",");
|
||||
const finalDb = explicitDb || dbNameFromConn || "";
|
||||
const authSection = needsAuth
|
||||
? `${encodeURIComponent(finalUser)}:${encodeURIComponent(finalPass)}@`
|
||||
: "";
|
||||
const safeEncode = (value: string) => {
|
||||
try {
|
||||
const decoded = decodeURIComponent(value);
|
||||
if (decoded !== value) {
|
||||
return value;
|
||||
}
|
||||
} catch (e) {}
|
||||
return encodeURIComponent(value);
|
||||
};
|
||||
|
||||
const authSection = needsAuth
|
||||
? `${safeEncode(finalUser)}:${safeEncode(finalPass)}@`
|
||||
: "";
|
||||
|
||||
let finalUri = `${protocol}://${authSection}${finalHosts}`;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue