From 751f564c4a65aac41446b42f881cbe86260dbbee Mon Sep 17 00:00:00 2001 From: "Shishkevich D." <135337715+shishkevichd@users.noreply.github.com> Date: Sat, 8 Mar 2025 12:33:34 +0700 Subject: [PATCH] fix: base64 encoding on vmess/shadowsocks inbounds (#2736) --- web/assets/js/util/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index 57a6b95d..99c76377 100644 --- a/web/assets/js/util/index.js +++ b/web/assets/js/util/index.js @@ -515,17 +515,22 @@ class ClipboardManager { class Base64 { static encode(content = "", safe = false) { if (safe) { - return window.btoa(content) + return Base64.encode(content) .replace(/\+/g, '-') .replace(/=/g, '') .replace(/\//g, '_') } - return window.btoa(content) + return window.btoa( + String.fromCharCode(...new TextEncoder().encode(content)) + ) } static decode(content = "") { - return window.atob(content) + return new TextDecoder() + .decode( + Uint8Array.from(window.atob(content), c => c.charCodeAt(0)) + ) } }