Skip to content

Commit 751f564

Browse files
authored
fix: base64 encoding on vmess/shadowsocks inbounds (#2736)
1 parent 6658f64 commit 751f564

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

web/assets/js/util/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,22 @@ class ClipboardManager {
515515
class Base64 {
516516
static encode(content = "", safe = false) {
517517
if (safe) {
518-
return window.btoa(content)
518+
return Base64.encode(content)
519519
.replace(/\+/g, '-')
520520
.replace(/=/g, '')
521521
.replace(/\//g, '_')
522522
}
523523

524-
return window.btoa(content)
524+
return window.btoa(
525+
String.fromCharCode(...new TextEncoder().encode(content))
526+
)
525527
}
526528

527529
static decode(content = "") {
528-
return window.atob(content)
530+
return new TextDecoder()
531+
.decode(
532+
Uint8Array.from(window.atob(content), c => c.charCodeAt(0))
533+
)
529534
}
530535
}
531536

0 commit comments

Comments
 (0)