String.fromCharCode can not be called with too many arguments

issue5177
review21561002
This commit is contained in:
Cédric Krier committed 2015-12-27 19:20:54 +01:00
1 parent 4b23b2349a
commit fa4cccd39b
1 file changed
+10 -1
+10 -1
View File
@@ -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;