forcefully make a copy of the output buffer

This commit is contained in:
SheetJS 2024-04-14 22:24:58 -04:00
parent d5f23335d5
commit 8b85d78142
18 changed files with 1729 additions and 1702 deletions

View File

@ -59,7 +59,7 @@ ctest: ## Build browser test (into ctest/ subdirectory)
.PHONY: ctestserv
ctestserv: ## Start a test server on port 8000
@cd ctest && python -mSimpleHTTPServer
@cd cteset && python -mSimpleHTTPServer || python3 -mhttp.server || npx -y http-server -p 8000 .
.PHONY: baseline
baseline: ## Build test baselines

View File

@ -257,7 +257,10 @@ type DecoderMap = {[id:CPIndex]:Decoder};
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

View File

@ -246,7 +246,10 @@
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1224,7 +1224,10 @@ if (typeof module !== 'undefined' && module.exports && typeof DO_NOT_EXPORT_CODE
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

View File

@ -4897,7 +4897,10 @@ if (typeof module !== 'undefined' && module.exports && typeof DO_NOT_EXPORT_CODE
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

5
dist/cputils.js vendored
View File

@ -246,7 +246,10 @@
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

5
dist/sbcs.full.js vendored
View File

@ -357,7 +357,10 @@ if (typeof module !== 'undefined' && module.exports && typeof DO_NOT_EXPORT_CODE
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

File diff suppressed because it is too large Load Diff

View File

@ -246,7 +246,10 @@
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -51,7 +51,7 @@
var mdl +AD0 1024, mdb +AD0 Buffer.allocUnsafe(mdl)+ADs
var make+AF8-EE +AD0 function make+AF8-EE(E)+AHs
var EE +AD0 Buffer.allocUnsafe(65536)+ADs
for(var i +AD0 0+ADs i +ADw 65536+ADsAKwAr-i) EE+AFs-i+AF0 +AD0 0+ADs
for(var i +AD0 0+ADs i +ADw 65536+ADs-+-+-i) EE+AFs-i+AF0 +AD0 0+ADs
var keys +AD0 Object.keys(E), len +AD0 keys.length+ADs
for(var ee +AD0 0, e +AD0 keys+AFs-ee+AF0AOw ee +ADw len+ADs +-+-ee) +AHs
if(+ACE(e +AD0 keys+AFs-ee+AF0)) continue+ADs
@ -94,7 +94,7 @@
var sbcs+AF8-decode +AD0 function make+AF8-sbcs+AF8-decode(cp) +AHs
var D +AD0 cpt+AFs-cp+AF0.dec+ADs
var DD +AD0 Buffer.allocUnsafe(131072), d+AD0-0, c+AD0AIgAiADs
for(d+AD0-0+ADs-d+ADw-D.length+ADsAKwAr-d) +AHs
for(d+AD0-0+ADs-d+ADw-D.length+ADs-+-+-d) +AHs
if(+ACE(c+AD0-D+AFs-d+AF0)) continue+ADs
var w +AD0 c.charCodeAt(0)+ADs
DD+AFs-2+ACo-d+AF0 +AD0 w+ACY-255+ADs DD+AFs-2+ACo-d+-1+AF0 +AD0 w+AD4APg-8+ADs
@ -246,7 +246,10 @@
mdb+AFs-j+-+-+AF0 +AD0 128 +- (w+ACY-63)+ADs
+AH0
+AH0
if(+ACE-ofmt +AHwAfA ofmt +AD0APQA9 'buf') return mdb.slice(0,j)+ADs
if(+ACE-ofmt +AHwAfA ofmt +AD0APQA9 'buf') +AHs
var res +AD0 mdb.slice(0,j)+ADs
return has+AF8-buf +ACYAJg Buffer.isBuffer(res) ? Buffer+AF8-from(res) : res+ADs
+AH0
if(ofmt +ACEAPQA9 'arr') return mdb.slice(0,j).toString('binary')+ADs
return +AFsAXQ.slice.call(mdb, 0, j)+ADs
+AH0AOw
@ -312,7 +315,7 @@
w +AD0 E+AFs-isstr? data.charAt(i) : data+AFs-i+AF0AXQA7
if(w +AD4 255) +AHs
out+AFs-j+AF0 +AD0 w+AD4APg-8+ADs
out+AFsAKwAr-j+AF0 +AD0 w+ACY-255+ADs
out+AFs-+-+-j+AF0 +AD0 w+ACY-255+ADs
+AH0 else out+AFs-j+AF0 +AD0 w+ACY-255+ADs
+AH0
else if((M+AD0-magic+AFs-cp+AF0)) switch(M) +AHs
@ -323,18 +326,18 @@
if(w +ADwAPQ 0x007F) out+AFs-j+AF0 +AD0 w+ADs
else if(w +ADwAPQ 0x07FF) +AHs
out+AFs-j+AF0 +AD0 192 +- (w +AD4APg 6)+ADs
out+AFsAKwAr-j+AF0 +AD0 128 +- (w+ACY-63)+ADs
out+AFs-+-+-j+AF0 +AD0 128 +- (w+ACY-63)+ADs
+AH0 else if(w +AD4APQ 0xD800 +ACYAJg w +ADwAPQ 0xDFFF) +AHs
w -+AD0 0xD800+ADs
ww +AD0 (isstr ? data.charCodeAt(+-+-i) : data+AFsAKwAr-i+AF0.charCodeAt(0)) - 0xDC00 +- (w +ADwAPA 10)+ADs
ww +AD0 (isstr ? data.charCodeAt(+-+-i) : data+AFs-+-+-i+AF0.charCodeAt(0)) - 0xDC00 +- (w +ADwAPA 10)+ADs
out+AFs-j+AF0 +AD0 240 +- ((ww+AD4APgA+-18) +ACY 0x07)+ADs
out+AFsAKwAr-j+AF0 +AD0 144 +- ((ww+AD4APgA+-12) +ACY 0x3F)+ADs
out+AFsAKwAr-j+AF0 +AD0 128 +- ((ww+AD4APgA+-6) +ACY 0x3F)+ADs
out+AFsAKwAr-j+AF0 +AD0 128 +- (ww +ACY 0x3F)+ADs
out+AFs-+-+-j+AF0 +AD0 144 +- ((ww+AD4APgA+-12) +ACY 0x3F)+ADs
out+AFs-+-+-j+AF0 +AD0 128 +- ((ww+AD4APgA+-6) +ACY 0x3F)+ADs
out+AFs-+-+-j+AF0 +AD0 128 +- (ww +ACY 0x3F)+ADs
+AH0 else +AHs
out+AFs-j+AF0 +AD0 224 +- (w +AD4APg 12)+ADs
out+AFsAKwAr-j+AF0 +AD0 128 +- ((w +AD4APg 6)+ACY-63)+ADs
out+AFsAKwAr-j+AF0 +AD0 128 +- (w+ACY-63)+ADs
out+AFs-+-+-j+AF0 +AD0 128 +- ((w +AD4APg 6)+ACY-63)+ADs
out+AFs-+-+-j+AF0 +AD0 128 +- (w+ACY-63)+ADs
+AH0
+AH0
break+ADs
@ -364,7 +367,7 @@
case +ACI-utf32le+ACI:
for(i +AD0 0+ADs i +ADw len+ADs +-+-i) +AHs
w +AD0 isstr ? data.charCodeAt(i) : data+AFs-i+AF0.charCodeAt(0)+ADs
if(w +AD4APQ 0xD800 +ACYAJg w +ADwAPQ 0xDFFF) w +AD0 0x10000 +- ((w - 0xD800) +ADwAPA 10) +- (data+AFsAKwAr-i+AF0.charCodeAt(0) - 0xDC00)+ADs
if(w +AD4APQ 0xD800 +ACYAJg w +ADwAPQ 0xDFFF) w +AD0 0x10000 +- ((w - 0xD800) +ADwAPA 10) +- (data+AFs-+-+-i+AF0.charCodeAt(0) - 0xDC00)+ADs
out+AFs-j+-+-+AF0 +AD0 w+ACY-255+ADs w +AD4APgA9 8+ADs
out+AFs-j+-+-+AF0 +AD0 w+ACY-255+ADs w +AD4APgA9 8+ADs
out+AFs-j+-+-+AF0 +AD0 w+ACY-255+ADs w +AD4APgA9 8+ADs
@ -374,7 +377,7 @@
case +ACI-utf32be+ACI:
for(i +AD0 0+ADs i +ADw len+ADs +-+-i) +AHs
w +AD0 isstr ? data.charCodeAt(i) : data+AFs-i+AF0.charCodeAt(0)+ADs
if(w +AD4APQ 0xD800 +ACYAJg w +ADwAPQ 0xDFFF) w +AD0 0x10000 +- ((w - 0xD800) +ADwAPA 10) +- (data+AFsAKwAr-i+AF0.charCodeAt(0) - 0xDC00)+ADs
if(w +AD4APQ 0xD800 +ACYAJg w +ADwAPQ 0xDFFF) w +AD0 0x10000 +- ((w - 0xD800) +ADwAPA 10) +- (data+AFs-+-+-i+AF0.charCodeAt(0) - 0xDC00)+ADs
out+AFs-j+-3+AF0 +AD0 w+ACY-255+ADs w +AD4APgA9 8+ADs
out+AFs-j+-2+AF0 +AD0 w+ACY-255+ADs w +AD4APgA9 8+ADs
out+AFs-j+-1+AF0 +AD0 w+ACY-255+ADs w +AD4APgA9 8+ADs
@ -385,7 +388,7 @@
case +ACI-utf7+ACI:
for(i +AD0 0+ADs i +ADw len+ADs i+-+-) +AHs
var c +AD0 isstr ? data.charAt(i) : data+AFs-i+AF0.charAt(0)+ADs
if(c +AD0APQA9 +ACIAKwAi) +AHs out+AFs-j+-+-+AF0 +AD0 0x2b+ADs out+AFs-j+-+-+AF0 +AD0 0x2d+ADs continue+ADs +AH0
if(c +AD0APQA9 +ACI-+-+ACI) +AHs out+AFs-j+-+-+AF0 +AD0 0x2b+ADs out+AFs-j+-+-+AF0 +AD0 0x2d+ADs continue+ADs +AH0
if(SetD.indexOf(c) +AD4 -1) +AHs out+AFs-j+-+-+AF0 +AD0 c.charCodeAt(0)+ADs continue+ADs +AH0
var tt +AD0 encode(1201, c)+ADs
out+AFs-j+-+-+AF0 +AD0 0x2b+ADs
@ -490,7 +493,7 @@
for(+ADs i +ADw len+ADs i+-+AD0-j) +AHs
if(data+AFs-i+AF0 +ACEAPQA9 0x2b) +AHs j+AD0-1+ADs out+AFs-k+-+-+AF0 +AD0 String.fromCharCode(data+AFs-i+AF0)+ADs continue+ADs +AH0
j+AD0-1+ADs
if(data+AFs-i+-1+AF0 +AD0APQA9 0x2d) +AHs j +AD0 2+ADs out+AFs-k+-+-+AF0 +AD0 +ACIAKwAiADs continue+ADs +AH0
if(data+AFs-i+-1+AF0 +AD0APQA9 0x2d) +AHs j +AD0 2+ADs out+AFs-k+-+-+AF0 +AD0 +ACI-+-+ACIAOw continue+ADs +AH0
// eslint-disable-next-line no-useless-escape
while(String.fromCharCode(data+AFs-i+-j+AF0).match(/+AFs-A-Za-z0-9+-+AFw-/+AF0-/)) j+-+-+ADs
var dash +AD0 0+ADs

View File

@ -246,7 +246,10 @@
mdb[j++] = 128 + (w&63);
}
}
if(!ofmt || ofmt === 'buf') return mdb.slice(0,j);
if(!ofmt || ofmt === 'buf') {
var res = mdb.slice(0,j);
return has_buf && Buffer.isBuffer(res) ? Buffer_from(res) : res;
}
if(ofmt !== 'arr') return mdb.slice(0,j).toString('binary');
return [].slice.call(mdb, 0, j);
};

View File

@ -1,6 +1,6 @@
{
"name": "codepage",
"version": "1.15.0",
"version": "1.15.0+pi",
"author": "SheetJS",
"description": "pure-JS library to handle codepages",
"keywords": [