From c021d5c1643f9629b70bbb7a0395d29ea18d1dfd Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 11 Oct 2026 20:49:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(mirror):=20ws=20=E6=8A=93=E5=8C=85=20ToBase?= =?UTF-8?q?64=20=E5=88=86=E5=9D=97=E9=99=8D=E5=88=B0=208192=EF=BC=8C?= =?UTF-8?q?=E8=BF=9C=E7=A6=BB=20apply=20=E5=AE=9E=E5=8F=82=E4=B8=8A?= =?UTF-8?q?=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - String.fromCharCode.apply 会把参数数组整包展开成实参,块过大必爆栈(V8 上限约 6.5 万);原 32768 虽安全但偏高,降到 8192 --- sockets/ws_hook.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sockets/ws_hook.js b/sockets/ws_hook.js index 0bc3563..b570153 100644 --- a/sockets/ws_hook.js +++ b/sockets/ws_hook.js @@ -37,7 +37,9 @@ } function ToBase64(Bytes) { var S = ''; - var Chunk = 0x8000; // 分块,避免超长字符串参数 + // 注意:String.fromCharCode.apply 会把参数数组整包展开成实参,块太大必然爆栈 + //(V8 实参上限约 6.5 万)。这里每块 8192 字节,远低于上限,且比逐字节拼接快得多。 + var Chunk = 0x2000; for (var I = 0; I < Bytes.length; I += Chunk) { S += String.fromCharCode.apply(null, Bytes.subarray(I, I + Chunk)); }