From fa4cccd39bcbbe939356e2f6ef13b6e82049378f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 27 Dec 2015 19:20:54 +0100 Subject: [PATCH] String.fromCharCode can not be called with too many arguments issue5177 review21561002 --- src/rpc.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rpc.js b/src/rpc.js index 10988b4389..f82ca2f43e 100644 --- a/src/rpc.js +++ b/src/rpc.js @@ -223,9 +223,18 @@ parent[index] = value; } } else if (value instanceof Uint8Array) { + var strings = [], chunksize = 0xffff; + // JavaScript Core has hard-coded argument limit of 65536 + // String.fromCharCode can not be called with too many + // arguments + for (var j = 0; j * chunksize < value.length; j++) { + strings.push(String.fromCharCode.apply( + null, value.subarray( + j * chunksize, (j + 1) * chunksize))); + } value = { '__class__': 'bytes', - 'base64': btoa(String.fromCharCode.apply(null, value)) + 'base64': btoa(strings.join('')) }; if (parent) { parent[index] = value;