diff --git a/src/connectors/captcha.ts b/src/connectors/captcha.ts index 56f9a10239..d1110e8892 100644 --- a/src/connectors/captcha.ts +++ b/src/connectors/captcha.ts @@ -45,7 +45,7 @@ async function start() { let decodedData: any; try { - decodedData = JSON.parse(b64Decode(data)); + decodedData = JSON.parse(b64Decode(data, true)); } catch (e) { error("Cannot parse data."); return; diff --git a/src/connectors/common.ts b/src/connectors/common.ts index c822dc2b2d..a8855f1d4b 100644 --- a/src/connectors/common.ts +++ b/src/connectors/common.ts @@ -15,7 +15,11 @@ export function getQsParam(name: string) { return decodeURIComponent(results[2].replace(/\+/g, " ")); } -export function b64Decode(str: string) { +export function b64Decode(str: string, spaceAsPlus = false) { + if (spaceAsPlus) { + str = str.replace(/ /g, "+"); + } + return decodeURIComponent( Array.prototype.map .call(atob(str), (c: string) => {