From 8d494e816604949d897d78fb503e35ed5c38352d Mon Sep 17 00:00:00 2001 From: Inplex-sys <69421356+Inplex-sys@users.noreply.github.com> Date: Mon, 14 Apr 2025 19:32:22 +0200 Subject: [PATCH 1/2] fix: improve URL decoding by replacing plus signs with spaces --- src/compose.ts | 6 +++--- src/deuri.ts | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/compose.ts b/src/compose.ts index d1eac38d..17302164 100644 --- a/src/compose.ts +++ b/src/compose.ts @@ -898,12 +898,12 @@ export const composeHandler = ({ `if(a${index}===undefined)` + `a${index}=[]\n` + `if(memory===-1){` + - `const temp=decodeURIComponent(url.slice(start)).replace(/\\+/g,' ')\n` + + `const temp=decodeURIComponent(url.slice(start))\n` + `if(temp.includes(',')){a${index}=a${index}.concat(temp.split(','))}` + - `else{a${index}.push(decodeURIComponent(url.slice(start)).replace(/\\+/g,' '))}\n` + + `else{a${index}.push(decodeURIComponent(url.slice(start)))}\n` + `break` + `}else{` + - `const temp=decodeURIComponent(url.slice(start, memory)).replace(/\\+/g,' ')\n` + + `const temp=decodeURIComponent(url.slice(start, memory))\n` + `if(temp.includes(',')){a${index}=a${index}.concat(temp.split(','))}` + `else{a${index}.push(temp)}\n` + `}` + diff --git a/src/deuri.ts b/src/deuri.ts index 1741620c..6b457ca5 100644 --- a/src/deuri.ts +++ b/src/deuri.ts @@ -115,6 +115,9 @@ export const decode = (url: string): string | null => { let percentPosition = url.indexOf('%') if (percentPosition === -1) return url + // Ensure that not encoded plus signs are replaced with spaces + url = url.replace(/\+/g, ' ') + // Ensure percentPosition always has 2 chars after let end = url.length - 3 if (percentPosition > end) return null @@ -151,7 +154,7 @@ export const decode = (url: string): string | null => { start = percentPosition + 3 percentPosition = url.indexOf('%', start) - if (percentPosition === -1) return decoded + url.substring(start) + if (percentPosition === -1) {console.log("ccc", decoded + url.substring(start)); return decoded + url.substring(start)} // Ensure percentPosition always has 2 chars after if (percentPosition > end) return null From 4907bc0c1e1074dc270c10aeeacc9cc265849f91 Mon Sep 17 00:00:00 2001 From: Inplex-sys <69421356+Inplex-sys@users.noreply.github.com> Date: Tue, 15 Apr 2025 15:56:16 +0200 Subject: [PATCH 2/2] fix: removing logging --- src/deuri.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deuri.ts b/src/deuri.ts index 6b457ca5..2b4b4985 100644 --- a/src/deuri.ts +++ b/src/deuri.ts @@ -154,7 +154,7 @@ export const decode = (url: string): string | null => { start = percentPosition + 3 percentPosition = url.indexOf('%', start) - if (percentPosition === -1) {console.log("ccc", decoded + url.substring(start)); return decoded + url.substring(start)} + if (percentPosition === -1) return decoded + url.substring(start) // Ensure percentPosition always has 2 chars after if (percentPosition > end) return null