From 90097b9bef3b843f316b7585f351f7707e26ecdf Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Wed, 2 Mar 2022 15:49:35 -0500 Subject: [PATCH] Fix mobile `+` url encoding issue (#1510) (cherry picked from commit 6e8c15bccd31a5fda189d4510a62753a6a5c6d1b) --- src/connectors/captcha.ts | 2 +- src/connectors/common.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/connectors/captcha.ts b/src/connectors/captcha.ts index e66d6b07..f42ff36f 100644 --- a/src/connectors/captcha.ts +++ b/src/connectors/captcha.ts @@ -47,7 +47,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 508fed5f..4801cf60 100644 --- a/src/connectors/common.ts +++ b/src/connectors/common.ts @@ -14,7 +14,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) => {