@zip.js/zip.js 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BENCHMARKS.md +350 -454
- package/deno.json +1 -1
- package/dist/zip-core-external.js +342 -120
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +340 -113
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +342 -120
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +340 -113
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +342 -120
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +342 -115
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +346 -124
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +342 -115
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-module.wasm +0 -0
- package/dist/zip-native.js +342 -115
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +346 -124
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +342 -115
- package/index-native.min.js +1 -1
- package/index.cjs +346 -124
- package/index.d.cts +20 -13
- package/index.d.ts +20 -13
- package/index.min.js +1 -1
- package/lib/core/codec-pool.js +35 -19
- package/lib/core/codec-worker.js +9 -6
- package/lib/core/streams/codecs/aes-hmac-sha1.js +194 -56
- package/lib/core/streams/zip-entry-stream.js +18 -10
- package/lib/core/streams/zlib-wasm/zlib-streams.js +2 -7
- package/lib/core/streams/zlib-wasm/zlib-streams.wasm +0 -0
- package/lib/core/util/decode-text.js +15 -1
- package/lib/core/version.js +1 -1
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-reader.js +65 -16
- package/lib/core/zlib-streams-inline.js +1 -1
- package/package.json +1 -1
|
@@ -763,7 +763,7 @@ const BLOCK_LENGTH$1 = 16;
|
|
|
763
763
|
const ROUND_KEYS_LENGTH = 60;
|
|
764
764
|
const SHA1_BLOCK_LENGTH = 64;
|
|
765
765
|
const SHA1_DIGEST_LENGTH = 20;
|
|
766
|
-
const SHA1_SCHEDULE_LENGTH =
|
|
766
|
+
const SHA1_SCHEDULE_LENGTH = 16;
|
|
767
767
|
const SHA1_LENGTH_OFFSET = 56;
|
|
768
768
|
const SHA1_PADDING = new Uint8Array([0x80]);
|
|
769
769
|
const SHA1_ZERO = new Uint8Array(1);
|
|
@@ -782,9 +782,12 @@ function createEngine$2(key, authenticationKey) {
|
|
|
782
782
|
initTables();
|
|
783
783
|
const roundKeys = new Int32Array(ROUND_KEYS_LENGTH);
|
|
784
784
|
const rounds = expandKey(key, roundKeys);
|
|
785
|
-
const counter = new Uint8Array(BLOCK_LENGTH$1);
|
|
786
785
|
const keystream = new Int32Array(BLOCK_LENGTH$1 / 4);
|
|
787
786
|
const hmac = createHmac(authenticationKey);
|
|
787
|
+
let counter0 = 0;
|
|
788
|
+
let counter1 = 0;
|
|
789
|
+
let counter2 = 0;
|
|
790
|
+
let counter3 = 0;
|
|
788
791
|
return {
|
|
789
792
|
process(data, decrypt) {
|
|
790
793
|
if (decrypt) {
|
|
@@ -820,31 +823,83 @@ function createEngine$2(key, authenticationKey) {
|
|
|
820
823
|
}
|
|
821
824
|
|
|
822
825
|
function nextKeystream() {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
let
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
826
|
+
counter0 = (counter0 + 1) | 0;
|
|
827
|
+
if (!counter0) {
|
|
828
|
+
counter1 = (counter1 + 1) | 0;
|
|
829
|
+
if (!counter1) {
|
|
830
|
+
counter2 = (counter2 + 1) | 0;
|
|
831
|
+
if (!counter2) {
|
|
832
|
+
counter3 = (counter3 + 1) | 0;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
let s0 = swapBytes(counter0) ^ roundKeys[0];
|
|
837
|
+
let s1 = swapBytes(counter1) ^ roundKeys[1];
|
|
838
|
+
let s2 = swapBytes(counter2) ^ roundKeys[2];
|
|
839
|
+
let s3 = swapBytes(counter3) ^ roundKeys[3];
|
|
840
|
+
let t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[4];
|
|
841
|
+
let t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[5];
|
|
842
|
+
let t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[6];
|
|
843
|
+
let t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[7];
|
|
844
|
+
s0 = T0[t0 >>> 24] ^ T1[(t1 >>> 16) & 255] ^ T2[(t2 >>> 8) & 255] ^ T3[t3 & 255] ^ roundKeys[8];
|
|
845
|
+
s1 = T0[t1 >>> 24] ^ T1[(t2 >>> 16) & 255] ^ T2[(t3 >>> 8) & 255] ^ T3[t0 & 255] ^ roundKeys[9];
|
|
846
|
+
s2 = T0[t2 >>> 24] ^ T1[(t3 >>> 16) & 255] ^ T2[(t0 >>> 8) & 255] ^ T3[t1 & 255] ^ roundKeys[10];
|
|
847
|
+
s3 = T0[t3 >>> 24] ^ T1[(t0 >>> 16) & 255] ^ T2[(t1 >>> 8) & 255] ^ T3[t2 & 255] ^ roundKeys[11];
|
|
848
|
+
t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[12];
|
|
849
|
+
t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[13];
|
|
850
|
+
t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[14];
|
|
851
|
+
t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[15];
|
|
852
|
+
s0 = T0[t0 >>> 24] ^ T1[(t1 >>> 16) & 255] ^ T2[(t2 >>> 8) & 255] ^ T3[t3 & 255] ^ roundKeys[16];
|
|
853
|
+
s1 = T0[t1 >>> 24] ^ T1[(t2 >>> 16) & 255] ^ T2[(t3 >>> 8) & 255] ^ T3[t0 & 255] ^ roundKeys[17];
|
|
854
|
+
s2 = T0[t2 >>> 24] ^ T1[(t3 >>> 16) & 255] ^ T2[(t0 >>> 8) & 255] ^ T3[t1 & 255] ^ roundKeys[18];
|
|
855
|
+
s3 = T0[t3 >>> 24] ^ T1[(t0 >>> 16) & 255] ^ T2[(t1 >>> 8) & 255] ^ T3[t2 & 255] ^ roundKeys[19];
|
|
856
|
+
t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[20];
|
|
857
|
+
t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[21];
|
|
858
|
+
t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[22];
|
|
859
|
+
t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[23];
|
|
860
|
+
s0 = T0[t0 >>> 24] ^ T1[(t1 >>> 16) & 255] ^ T2[(t2 >>> 8) & 255] ^ T3[t3 & 255] ^ roundKeys[24];
|
|
861
|
+
s1 = T0[t1 >>> 24] ^ T1[(t2 >>> 16) & 255] ^ T2[(t3 >>> 8) & 255] ^ T3[t0 & 255] ^ roundKeys[25];
|
|
862
|
+
s2 = T0[t2 >>> 24] ^ T1[(t3 >>> 16) & 255] ^ T2[(t0 >>> 8) & 255] ^ T3[t1 & 255] ^ roundKeys[26];
|
|
863
|
+
s3 = T0[t3 >>> 24] ^ T1[(t0 >>> 16) & 255] ^ T2[(t1 >>> 8) & 255] ^ T3[t2 & 255] ^ roundKeys[27];
|
|
864
|
+
t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[28];
|
|
865
|
+
t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[29];
|
|
866
|
+
t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[30];
|
|
867
|
+
t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[31];
|
|
868
|
+
s0 = T0[t0 >>> 24] ^ T1[(t1 >>> 16) & 255] ^ T2[(t2 >>> 8) & 255] ^ T3[t3 & 255] ^ roundKeys[32];
|
|
869
|
+
s1 = T0[t1 >>> 24] ^ T1[(t2 >>> 16) & 255] ^ T2[(t3 >>> 8) & 255] ^ T3[t0 & 255] ^ roundKeys[33];
|
|
870
|
+
s2 = T0[t2 >>> 24] ^ T1[(t3 >>> 16) & 255] ^ T2[(t0 >>> 8) & 255] ^ T3[t1 & 255] ^ roundKeys[34];
|
|
871
|
+
s3 = T0[t3 >>> 24] ^ T1[(t0 >>> 16) & 255] ^ T2[(t1 >>> 8) & 255] ^ T3[t2 & 255] ^ roundKeys[35];
|
|
872
|
+
t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[36];
|
|
873
|
+
t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[37];
|
|
874
|
+
t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[38];
|
|
875
|
+
t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[39];
|
|
876
|
+
let indexKey = 40;
|
|
877
|
+
if (rounds > 10) {
|
|
878
|
+
s0 = T0[t0 >>> 24] ^ T1[(t1 >>> 16) & 255] ^ T2[(t2 >>> 8) & 255] ^ T3[t3 & 255] ^ roundKeys[40];
|
|
879
|
+
s1 = T0[t1 >>> 24] ^ T1[(t2 >>> 16) & 255] ^ T2[(t3 >>> 8) & 255] ^ T3[t0 & 255] ^ roundKeys[41];
|
|
880
|
+
s2 = T0[t2 >>> 24] ^ T1[(t3 >>> 16) & 255] ^ T2[(t0 >>> 8) & 255] ^ T3[t1 & 255] ^ roundKeys[42];
|
|
881
|
+
s3 = T0[t3 >>> 24] ^ T1[(t0 >>> 16) & 255] ^ T2[(t1 >>> 8) & 255] ^ T3[t2 & 255] ^ roundKeys[43];
|
|
882
|
+
t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[44];
|
|
883
|
+
t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[45];
|
|
884
|
+
t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[46];
|
|
885
|
+
t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[47];
|
|
886
|
+
indexKey = 48;
|
|
887
|
+
}
|
|
888
|
+
if (rounds > 12) {
|
|
889
|
+
s0 = T0[t0 >>> 24] ^ T1[(t1 >>> 16) & 255] ^ T2[(t2 >>> 8) & 255] ^ T3[t3 & 255] ^ roundKeys[48];
|
|
890
|
+
s1 = T0[t1 >>> 24] ^ T1[(t2 >>> 16) & 255] ^ T2[(t3 >>> 8) & 255] ^ T3[t0 & 255] ^ roundKeys[49];
|
|
891
|
+
s2 = T0[t2 >>> 24] ^ T1[(t3 >>> 16) & 255] ^ T2[(t0 >>> 8) & 255] ^ T3[t1 & 255] ^ roundKeys[50];
|
|
892
|
+
s3 = T0[t3 >>> 24] ^ T1[(t0 >>> 16) & 255] ^ T2[(t1 >>> 8) & 255] ^ T3[t2 & 255] ^ roundKeys[51];
|
|
893
|
+
t0 = T0[s0 >>> 24] ^ T1[(s1 >>> 16) & 255] ^ T2[(s2 >>> 8) & 255] ^ T3[s3 & 255] ^ roundKeys[52];
|
|
894
|
+
t1 = T0[s1 >>> 24] ^ T1[(s2 >>> 16) & 255] ^ T2[(s3 >>> 8) & 255] ^ T3[s0 & 255] ^ roundKeys[53];
|
|
895
|
+
t2 = T0[s2 >>> 24] ^ T1[(s3 >>> 16) & 255] ^ T2[(s0 >>> 8) & 255] ^ T3[s1 & 255] ^ roundKeys[54];
|
|
896
|
+
t3 = T0[s3 >>> 24] ^ T1[(s0 >>> 16) & 255] ^ T2[(s1 >>> 8) & 255] ^ T3[s2 & 255] ^ roundKeys[55];
|
|
897
|
+
indexKey = 56;
|
|
898
|
+
}
|
|
899
|
+
keystream[0] = ((S_BOX[t0 >>> 24] << 24) | (S_BOX[(t1 >>> 16) & 255] << 16) | (S_BOX[(t2 >>> 8) & 255] << 8) | S_BOX[t3 & 255]) ^ roundKeys[indexKey];
|
|
900
|
+
keystream[1] = ((S_BOX[t1 >>> 24] << 24) | (S_BOX[(t2 >>> 16) & 255] << 16) | (S_BOX[(t3 >>> 8) & 255] << 8) | S_BOX[t0 & 255]) ^ roundKeys[indexKey + 1];
|
|
901
|
+
keystream[2] = ((S_BOX[t2 >>> 24] << 24) | (S_BOX[(t3 >>> 16) & 255] << 16) | (S_BOX[(t0 >>> 8) & 255] << 8) | S_BOX[t1 & 255]) ^ roundKeys[indexKey + 2];
|
|
902
|
+
keystream[3] = ((S_BOX[t3 >>> 24] << 24) | (S_BOX[(t0 >>> 16) & 255] << 16) | (S_BOX[(t1 >>> 8) & 255] << 8) | S_BOX[t2 & 255]) ^ roundKeys[indexKey + 3];
|
|
848
903
|
}
|
|
849
904
|
}
|
|
850
905
|
|
|
@@ -968,47 +1023,126 @@ function createSha1() {
|
|
|
968
1023
|
for (let index = 0; index < 16; index++) {
|
|
969
1024
|
schedule[index] = view.getInt32(offset + 4 * index);
|
|
970
1025
|
}
|
|
971
|
-
for (let index = 16; index < SHA1_SCHEDULE_LENGTH; index++) {
|
|
972
|
-
const word = schedule[index - 3] ^ schedule[index - 8] ^ schedule[index - 14] ^ schedule[index - 16];
|
|
973
|
-
schedule[index] = (word << 1) | (word >>> 31);
|
|
974
|
-
}
|
|
975
1026
|
let a = state[0];
|
|
976
1027
|
let b = state[1];
|
|
977
1028
|
let c = state[2];
|
|
978
1029
|
let d = state[3];
|
|
979
1030
|
let e = state[4];
|
|
980
1031
|
let t;
|
|
981
|
-
for (let index = 0; index <
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
d = c;
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1032
|
+
for (let index = 0; index < 15; index += 5) {
|
|
1033
|
+
e = (((a << 5) | (a >>> 27)) + (((c ^ d) & b) ^ d) + e + 0x5A827999 + schedule[index]) | 0;
|
|
1034
|
+
b = (b << 30) | (b >>> 2);
|
|
1035
|
+
d = (((e << 5) | (e >>> 27)) + (((b ^ c) & a) ^ c) + d + 0x5A827999 + schedule[index + 1]) | 0;
|
|
1036
|
+
a = (a << 30) | (a >>> 2);
|
|
1037
|
+
c = (((d << 5) | (d >>> 27)) + (((a ^ b) & e) ^ b) + c + 0x5A827999 + schedule[index + 2]) | 0;
|
|
1038
|
+
e = (e << 30) | (e >>> 2);
|
|
1039
|
+
b = (((c << 5) | (c >>> 27)) + (((e ^ a) & d) ^ a) + b + 0x5A827999 + schedule[index + 3]) | 0;
|
|
1040
|
+
d = (d << 30) | (d >>> 2);
|
|
1041
|
+
a = (((b << 5) | (b >>> 27)) + (((d ^ e) & c) ^ e) + a + 0x5A827999 + schedule[index + 4]) | 0;
|
|
1042
|
+
c = (c << 30) | (c >>> 2);
|
|
1043
|
+
}
|
|
1044
|
+
e = (((a << 5) | (a >>> 27)) + (((c ^ d) & b) ^ d) + e + 0x5A827999 + schedule[15]) | 0;
|
|
1045
|
+
b = (b << 30) | (b >>> 2);
|
|
1046
|
+
t = schedule[13] ^ schedule[8] ^ schedule[2] ^ schedule[0];
|
|
1047
|
+
t = (t << 1) | (t >>> 31);
|
|
1048
|
+
schedule[0] = t;
|
|
1049
|
+
d = (((e << 5) | (e >>> 27)) + (((b ^ c) & a) ^ c) + d + 0x5A827999 + t) | 0;
|
|
1050
|
+
a = (a << 30) | (a >>> 2);
|
|
1051
|
+
t = schedule[14] ^ schedule[9] ^ schedule[3] ^ schedule[1];
|
|
1052
|
+
t = (t << 1) | (t >>> 31);
|
|
1053
|
+
schedule[1] = t;
|
|
1054
|
+
c = (((d << 5) | (d >>> 27)) + (((a ^ b) & e) ^ b) + c + 0x5A827999 + t) | 0;
|
|
1055
|
+
e = (e << 30) | (e >>> 2);
|
|
1056
|
+
t = schedule[15] ^ schedule[10] ^ schedule[4] ^ schedule[2];
|
|
1057
|
+
t = (t << 1) | (t >>> 31);
|
|
1058
|
+
schedule[2] = t;
|
|
1059
|
+
b = (((c << 5) | (c >>> 27)) + (((e ^ a) & d) ^ a) + b + 0x5A827999 + t) | 0;
|
|
1060
|
+
d = (d << 30) | (d >>> 2);
|
|
1061
|
+
t = schedule[0] ^ schedule[11] ^ schedule[5] ^ schedule[3];
|
|
1062
|
+
t = (t << 1) | (t >>> 31);
|
|
1063
|
+
schedule[3] = t;
|
|
1064
|
+
a = (((b << 5) | (b >>> 27)) + (((d ^ e) & c) ^ e) + a + 0x5A827999 + t) | 0;
|
|
1065
|
+
c = (c << 30) | (c >>> 2);
|
|
1066
|
+
for (let index = 20; index < 40; index += 5) {
|
|
1067
|
+
t = schedule[(index - 3) & 15] ^ schedule[(index - 8) & 15] ^ schedule[(index - 14) & 15] ^ schedule[(index) & 15];
|
|
1068
|
+
t = (t << 1) | (t >>> 31);
|
|
1069
|
+
schedule[(index) & 15] = t;
|
|
1070
|
+
e = (((a << 5) | (a >>> 27)) + (b ^ c ^ d) + e + 0x6ED9EBA1 + t) | 0;
|
|
1071
|
+
b = (b << 30) | (b >>> 2);
|
|
1072
|
+
t = schedule[(index - 2) & 15] ^ schedule[(index - 7) & 15] ^ schedule[(index - 13) & 15] ^ schedule[(index + 1) & 15];
|
|
1073
|
+
t = (t << 1) | (t >>> 31);
|
|
1074
|
+
schedule[(index + 1) & 15] = t;
|
|
1075
|
+
d = (((e << 5) | (e >>> 27)) + (a ^ b ^ c) + d + 0x6ED9EBA1 + t) | 0;
|
|
1076
|
+
a = (a << 30) | (a >>> 2);
|
|
1077
|
+
t = schedule[(index - 1) & 15] ^ schedule[(index - 6) & 15] ^ schedule[(index - 12) & 15] ^ schedule[(index + 2) & 15];
|
|
1078
|
+
t = (t << 1) | (t >>> 31);
|
|
1079
|
+
schedule[(index + 2) & 15] = t;
|
|
1080
|
+
c = (((d << 5) | (d >>> 27)) + (e ^ a ^ b) + c + 0x6ED9EBA1 + t) | 0;
|
|
1081
|
+
e = (e << 30) | (e >>> 2);
|
|
1082
|
+
t = schedule[(index) & 15] ^ schedule[(index - 5) & 15] ^ schedule[(index - 11) & 15] ^ schedule[(index + 3) & 15];
|
|
1083
|
+
t = (t << 1) | (t >>> 31);
|
|
1084
|
+
schedule[(index + 3) & 15] = t;
|
|
1085
|
+
b = (((c << 5) | (c >>> 27)) + (d ^ e ^ a) + b + 0x6ED9EBA1 + t) | 0;
|
|
1086
|
+
d = (d << 30) | (d >>> 2);
|
|
1087
|
+
t = schedule[(index + 1) & 15] ^ schedule[(index - 4) & 15] ^ schedule[(index - 10) & 15] ^ schedule[(index + 4) & 15];
|
|
1088
|
+
t = (t << 1) | (t >>> 31);
|
|
1089
|
+
schedule[(index + 4) & 15] = t;
|
|
1090
|
+
a = (((b << 5) | (b >>> 27)) + (c ^ d ^ e) + a + 0x6ED9EBA1 + t) | 0;
|
|
1091
|
+
c = (c << 30) | (c >>> 2);
|
|
1092
|
+
}
|
|
1093
|
+
for (let index = 40; index < 60; index += 5) {
|
|
1094
|
+
t = schedule[(index - 3) & 15] ^ schedule[(index - 8) & 15] ^ schedule[(index - 14) & 15] ^ schedule[(index) & 15];
|
|
1095
|
+
t = (t << 1) | (t >>> 31);
|
|
1096
|
+
schedule[(index) & 15] = t;
|
|
1097
|
+
e = (((a << 5) | (a >>> 27)) + ((b & c) | ((b | c) & d)) + e + 0x8F1BBCDC + t) | 0;
|
|
1098
|
+
b = (b << 30) | (b >>> 2);
|
|
1099
|
+
t = schedule[(index - 2) & 15] ^ schedule[(index - 7) & 15] ^ schedule[(index - 13) & 15] ^ schedule[(index + 1) & 15];
|
|
1100
|
+
t = (t << 1) | (t >>> 31);
|
|
1101
|
+
schedule[(index + 1) & 15] = t;
|
|
1102
|
+
d = (((e << 5) | (e >>> 27)) + ((a & b) | ((a | b) & c)) + d + 0x8F1BBCDC + t) | 0;
|
|
1103
|
+
a = (a << 30) | (a >>> 2);
|
|
1104
|
+
t = schedule[(index - 1) & 15] ^ schedule[(index - 6) & 15] ^ schedule[(index - 12) & 15] ^ schedule[(index + 2) & 15];
|
|
1105
|
+
t = (t << 1) | (t >>> 31);
|
|
1106
|
+
schedule[(index + 2) & 15] = t;
|
|
1107
|
+
c = (((d << 5) | (d >>> 27)) + ((e & a) | ((e | a) & b)) + c + 0x8F1BBCDC + t) | 0;
|
|
1108
|
+
e = (e << 30) | (e >>> 2);
|
|
1109
|
+
t = schedule[(index) & 15] ^ schedule[(index - 5) & 15] ^ schedule[(index - 11) & 15] ^ schedule[(index + 3) & 15];
|
|
1110
|
+
t = (t << 1) | (t >>> 31);
|
|
1111
|
+
schedule[(index + 3) & 15] = t;
|
|
1112
|
+
b = (((c << 5) | (c >>> 27)) + ((d & e) | ((d | e) & a)) + b + 0x8F1BBCDC + t) | 0;
|
|
1113
|
+
d = (d << 30) | (d >>> 2);
|
|
1114
|
+
t = schedule[(index + 1) & 15] ^ schedule[(index - 4) & 15] ^ schedule[(index - 10) & 15] ^ schedule[(index + 4) & 15];
|
|
1115
|
+
t = (t << 1) | (t >>> 31);
|
|
1116
|
+
schedule[(index + 4) & 15] = t;
|
|
1117
|
+
a = (((b << 5) | (b >>> 27)) + ((c & d) | ((c | d) & e)) + a + 0x8F1BBCDC + t) | 0;
|
|
1118
|
+
c = (c << 30) | (c >>> 2);
|
|
1119
|
+
}
|
|
1120
|
+
for (let index = 60; index < 80; index += 5) {
|
|
1121
|
+
t = schedule[(index - 3) & 15] ^ schedule[(index - 8) & 15] ^ schedule[(index - 14) & 15] ^ schedule[(index) & 15];
|
|
1122
|
+
t = (t << 1) | (t >>> 31);
|
|
1123
|
+
schedule[(index) & 15] = t;
|
|
1124
|
+
e = (((a << 5) | (a >>> 27)) + (b ^ c ^ d) + e + 0xCA62C1D6 + t) | 0;
|
|
1125
|
+
b = (b << 30) | (b >>> 2);
|
|
1126
|
+
t = schedule[(index - 2) & 15] ^ schedule[(index - 7) & 15] ^ schedule[(index - 13) & 15] ^ schedule[(index + 1) & 15];
|
|
1127
|
+
t = (t << 1) | (t >>> 31);
|
|
1128
|
+
schedule[(index + 1) & 15] = t;
|
|
1129
|
+
d = (((e << 5) | (e >>> 27)) + (a ^ b ^ c) + d + 0xCA62C1D6 + t) | 0;
|
|
1130
|
+
a = (a << 30) | (a >>> 2);
|
|
1131
|
+
t = schedule[(index - 1) & 15] ^ schedule[(index - 6) & 15] ^ schedule[(index - 12) & 15] ^ schedule[(index + 2) & 15];
|
|
1132
|
+
t = (t << 1) | (t >>> 31);
|
|
1133
|
+
schedule[(index + 2) & 15] = t;
|
|
1134
|
+
c = (((d << 5) | (d >>> 27)) + (e ^ a ^ b) + c + 0xCA62C1D6 + t) | 0;
|
|
1135
|
+
e = (e << 30) | (e >>> 2);
|
|
1136
|
+
t = schedule[(index) & 15] ^ schedule[(index - 5) & 15] ^ schedule[(index - 11) & 15] ^ schedule[(index + 3) & 15];
|
|
1137
|
+
t = (t << 1) | (t >>> 31);
|
|
1138
|
+
schedule[(index + 3) & 15] = t;
|
|
1139
|
+
b = (((c << 5) | (c >>> 27)) + (d ^ e ^ a) + b + 0xCA62C1D6 + t) | 0;
|
|
1140
|
+
d = (d << 30) | (d >>> 2);
|
|
1141
|
+
t = schedule[(index + 1) & 15] ^ schedule[(index - 4) & 15] ^ schedule[(index - 10) & 15] ^ schedule[(index + 4) & 15];
|
|
1142
|
+
t = (t << 1) | (t >>> 31);
|
|
1143
|
+
schedule[(index + 4) & 15] = t;
|
|
1144
|
+
a = (((b << 5) | (b >>> 27)) + (c ^ d ^ e) + a + 0xCA62C1D6 + t) | 0;
|
|
1145
|
+
c = (c << 30) | (c >>> 2);
|
|
1012
1146
|
}
|
|
1013
1147
|
state[0] = (state[0] + a) | 0;
|
|
1014
1148
|
state[1] = (state[1] + b) | 0;
|
|
@@ -1071,6 +1205,10 @@ function substituteWord(word) {
|
|
|
1071
1205
|
return (S_BOX[word >>> 24] << 24) | (S_BOX[(word >>> 16) & 255] << 16) | (S_BOX[(word >>> 8) & 255] << 8) | S_BOX[word & 255];
|
|
1072
1206
|
}
|
|
1073
1207
|
|
|
1208
|
+
function swapBytes(value) {
|
|
1209
|
+
return (value << 24) | ((value & 0xff00) << 8) | ((value >>> 8) & 0xff00) | (value >>> 24);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1074
1212
|
function multiplyByTwo(value) {
|
|
1075
1213
|
return ((value << 1) ^ ((value >> 7) * 0x1b)) & 255;
|
|
1076
1214
|
}
|
|
@@ -1762,8 +1900,8 @@ class DeflateStream extends TransformStream {
|
|
|
1762
1900
|
let crc32Stream, encryptionStream, gzipCrc32Stream;
|
|
1763
1901
|
let readable = super.readable;
|
|
1764
1902
|
const codecStreams = format && getCodecStreams(format);
|
|
1765
|
-
const
|
|
1766
|
-
|
|
1903
|
+
const GzipCompressionStream = getGzipCompressionStream(useCompressionStream, CompressionStream, CompressionStreamFallback);
|
|
1904
|
+
const useGzipCrc32 = computeCrc32 && compressed && !deflate64 && !codecStreams && (!encrypted || zipCrypto) && Boolean(GzipCompressionStream);
|
|
1767
1905
|
if ((!encrypted || zipCrypto) && computeCrc32 && !useGzipCrc32) {
|
|
1768
1906
|
crc32Stream = new Crc32Stream();
|
|
1769
1907
|
readable = pipeThrough(readable, crc32Stream);
|
|
@@ -1773,7 +1911,7 @@ class DeflateStream extends TransformStream {
|
|
|
1773
1911
|
readable = pipeThroughBackpressured(readable, createCodecStream(codecStreams.CompressionStream, format, { level, chunkSize, compressionMethod, uncompressedSize: inputSize }));
|
|
1774
1912
|
} else if (useGzipCrc32) {
|
|
1775
1913
|
gzipCrc32Stream = new GzipToRawDeflateStream();
|
|
1776
|
-
readable = pipeThroughBackpressured(readable, new
|
|
1914
|
+
readable = pipeThroughBackpressured(readable, new GzipCompressionStream(FORMAT_GZIP$1, { level, chunkSize }));
|
|
1777
1915
|
readable = pipeThrough(readable, gzipCrc32Stream);
|
|
1778
1916
|
} else {
|
|
1779
1917
|
try {
|
|
@@ -1847,8 +1985,7 @@ class GzipToRawDeflateStream extends TransformStream {
|
|
|
1847
1985
|
}
|
|
1848
1986
|
}
|
|
1849
1987
|
|
|
1850
|
-
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize) {
|
|
1851
|
-
const crc32 = new Crc32();
|
|
1988
|
+
function pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, crc32) {
|
|
1852
1989
|
let outputLength = 0;
|
|
1853
1990
|
let inputDone = false;
|
|
1854
1991
|
let watchdogTimeout;
|
|
@@ -1922,7 +2059,7 @@ class InflateStream extends TransformStream {
|
|
|
1922
2059
|
constructor(options, { chunkSize, DecompressionStreamFallback, DecompressionStream }) {
|
|
1923
2060
|
super({});
|
|
1924
2061
|
const { zipCrypto, encrypted, checkCrc32, crc32, compressed, useCompressionStream, deflate64, format, compressionMethod, rawBitFlag, outputSize } = options;
|
|
1925
|
-
let crc32Stream, decryptionStream;
|
|
2062
|
+
let crc32Stream, decryptionStream, gzipCrc32;
|
|
1926
2063
|
let readable = super.readable;
|
|
1927
2064
|
if (encrypted) {
|
|
1928
2065
|
if (zipCrypto) {
|
|
@@ -1949,19 +2086,20 @@ class InflateStream extends TransformStream {
|
|
|
1949
2086
|
} catch {
|
|
1950
2087
|
throw error;
|
|
1951
2088
|
}
|
|
1952
|
-
|
|
2089
|
+
gzipCrc32 = new Crc32();
|
|
2090
|
+
readable = pipeThroughGzipDecompressionStream(readable, gzipStream, outputSize, gzipCrc32);
|
|
1953
2091
|
}
|
|
1954
2092
|
}
|
|
1955
2093
|
readable = mapInflateStreamError(readable);
|
|
1956
2094
|
}
|
|
1957
|
-
if (checkCrc32) {
|
|
2095
|
+
if (checkCrc32 && !gzipCrc32) {
|
|
1958
2096
|
crc32Stream = new Crc32Stream();
|
|
1959
2097
|
readable = pipeThrough(readable, crc32Stream);
|
|
1960
2098
|
}
|
|
1961
2099
|
setReadable(this, readable, () => {
|
|
1962
2100
|
if (checkCrc32) {
|
|
1963
|
-
const
|
|
1964
|
-
if (crc32 !=
|
|
2101
|
+
const computedCrc32 = gzipCrc32 ? gzipCrc32.get() >>> 0 : new DataView(crc32Stream.value.buffer).getUint32(0, false);
|
|
2102
|
+
if (crc32 != computedCrc32) {
|
|
1965
2103
|
throw new Error(ERR_INVALID_CRC32);
|
|
1966
2104
|
}
|
|
1967
2105
|
}
|
|
@@ -2017,6 +2155,14 @@ function createCodecStream(CodecStreamClass, format, options) {
|
|
|
2017
2155
|
return new CodecStreamClass(format, options);
|
|
2018
2156
|
}
|
|
2019
2157
|
|
|
2158
|
+
function getGzipCompressionStream(useCompressionStream, CompressionStreamNative, CompressionStreamFallback) {
|
|
2159
|
+
if (useCompressionStream && CompressionStreamNative) {
|
|
2160
|
+
return CompressionStreamNative;
|
|
2161
|
+
} else if (CompressionStreamFallback && CompressionStreamFallback.requiresModule) {
|
|
2162
|
+
return CompressionStreamFallback;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2020
2166
|
function pipeThroughCompressionStream(readable, useCompressionStream, options, CompressionStreamNative, CompressionStreamFallback) {
|
|
2021
2167
|
const Stream = useCompressionStream && CompressionStreamNative ?
|
|
2022
2168
|
CompressionStreamNative :
|
|
@@ -2368,7 +2514,8 @@ class CodecWorker {
|
|
|
2368
2514
|
return new Promise(resolve => {
|
|
2369
2515
|
const { worker, busy } = workerData;
|
|
2370
2516
|
if (busy) {
|
|
2371
|
-
workerData.
|
|
2517
|
+
workerData.terminateResolvers = workerData.terminateResolvers || [];
|
|
2518
|
+
workerData.terminateResolvers.push(resolve);
|
|
2372
2519
|
} else {
|
|
2373
2520
|
if (worker) {
|
|
2374
2521
|
worker.terminate();
|
|
@@ -2381,17 +2528,19 @@ class CodecWorker {
|
|
|
2381
2528
|
},
|
|
2382
2529
|
onTaskFinished() {
|
|
2383
2530
|
if (workerData.busy) {
|
|
2384
|
-
const {
|
|
2385
|
-
if (
|
|
2386
|
-
workerData.
|
|
2531
|
+
const { terminateResolvers, worker } = workerData;
|
|
2532
|
+
if (terminateResolvers) {
|
|
2533
|
+
workerData.terminateResolvers = null;
|
|
2387
2534
|
if (worker) {
|
|
2388
2535
|
workerData.terminated = true;
|
|
2389
2536
|
worker.terminate();
|
|
2390
2537
|
}
|
|
2391
|
-
resolveTerminated();
|
|
2392
2538
|
}
|
|
2393
2539
|
workerData.busy = false;
|
|
2394
|
-
onTaskFinished(workerData);
|
|
2540
|
+
const pendingTasks = onTaskFinished(workerData);
|
|
2541
|
+
if (terminateResolvers) {
|
|
2542
|
+
terminateResolvers.forEach(resolve => resolve(pendingTasks));
|
|
2543
|
+
}
|
|
2395
2544
|
}
|
|
2396
2545
|
}
|
|
2397
2546
|
});
|
|
@@ -3076,7 +3225,10 @@ async function runWorker(stream, workerOptions) {
|
|
|
3076
3225
|
|
|
3077
3226
|
function onTaskFinished(workerData) {
|
|
3078
3227
|
clearStarvationTimeout();
|
|
3079
|
-
if (
|
|
3228
|
+
if (workerData.terminated) {
|
|
3229
|
+
workerData.terminated = false;
|
|
3230
|
+
return runPendingRequestsInline();
|
|
3231
|
+
} else if (pendingRequests.length) {
|
|
3080
3232
|
const [{ resolve, stream, workerOptions }] = pendingRequests.splice(0, 1);
|
|
3081
3233
|
resolve(new CodecWorker(workerData, stream, workerOptions, onTaskFinished));
|
|
3082
3234
|
armStarvationTimeout();
|
|
@@ -3114,12 +3266,26 @@ function onWorkerStarvation() {
|
|
|
3114
3266
|
starvationTimeout = null;
|
|
3115
3267
|
if (pendingRequests.length) {
|
|
3116
3268
|
const [{ resolve, stream, workerOptions }] = pendingRequests.splice(0, 1);
|
|
3117
|
-
|
|
3118
|
-
resolve(new CodecWorker({}, stream, inlineWorkerOptions, onInlineTaskFinished));
|
|
3269
|
+
resolve(new CodecWorker({}, stream, getInlineWorkerOptions(workerOptions), onInlineTaskFinished));
|
|
3119
3270
|
armStarvationTimeout();
|
|
3120
3271
|
}
|
|
3121
3272
|
}
|
|
3122
3273
|
|
|
3274
|
+
function runPendingRequestsInline() {
|
|
3275
|
+
const tasks = pendingRequests.splice(0).map(({ resolve, stream, workerOptions }) => new Promise(resolveTask => {
|
|
3276
|
+
resolve(new CodecWorker({}, stream, getInlineWorkerOptions(workerOptions), () => {
|
|
3277
|
+
onInlineTaskFinished();
|
|
3278
|
+
resolveTask();
|
|
3279
|
+
}));
|
|
3280
|
+
}));
|
|
3281
|
+
clearStarvationTimeout();
|
|
3282
|
+
return Promise.all(tasks);
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
function getInlineWorkerOptions(workerOptions) {
|
|
3286
|
+
return Object.assign({}, workerOptions, { useWebWorkers: false, workerURI: UNDEFINED_VALUE, createWorker: UNDEFINED_VALUE });
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3123
3289
|
function onInlineTaskFinished() {
|
|
3124
3290
|
clearStarvationTimeout();
|
|
3125
3291
|
armStarvationTimeout();
|
|
@@ -3129,18 +3295,14 @@ function terminateWorker(workerData, workerOptions) {
|
|
|
3129
3295
|
const { config } = workerOptions;
|
|
3130
3296
|
const { terminateWorkerTimeout } = config;
|
|
3131
3297
|
if (Number.isFinite(terminateWorkerTimeout) && terminateWorkerTimeout >= 0) {
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
// ignored
|
|
3141
|
-
}
|
|
3142
|
-
}, terminateWorkerTimeout);
|
|
3143
|
-
}
|
|
3298
|
+
workerData.terminateTimeout = setTimeout(async () => {
|
|
3299
|
+
pool = pool.filter(data => data != workerData);
|
|
3300
|
+
try {
|
|
3301
|
+
await workerData.terminate();
|
|
3302
|
+
} catch {
|
|
3303
|
+
// ignored
|
|
3304
|
+
}
|
|
3305
|
+
}, terminateWorkerTimeout);
|
|
3144
3306
|
}
|
|
3145
3307
|
}
|
|
3146
3308
|
|
|
@@ -3153,10 +3315,13 @@ function clearTerminateTimeout(workerData) {
|
|
|
3153
3315
|
}
|
|
3154
3316
|
|
|
3155
3317
|
async function terminateWorkers() {
|
|
3156
|
-
await Promise.allSettled(
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3318
|
+
await Promise.allSettled([
|
|
3319
|
+
runPendingRequestsInline(),
|
|
3320
|
+
...pool.map(workerData => {
|
|
3321
|
+
clearTerminateTimeout(workerData);
|
|
3322
|
+
return workerData.terminate();
|
|
3323
|
+
})
|
|
3324
|
+
]);
|
|
3160
3325
|
resetWebWorkerSupport();
|
|
3161
3326
|
}
|
|
3162
3327
|
|
|
@@ -3231,6 +3396,19 @@ function decodeText(value, encoding) {
|
|
|
3231
3396
|
return decode(value, encoding, true);
|
|
3232
3397
|
}
|
|
3233
3398
|
|
|
3399
|
+
function isUTF8Text(value) {
|
|
3400
|
+
if (value.some(byte => byte > 0x7f)) {
|
|
3401
|
+
try {
|
|
3402
|
+
new TextDecoder("utf-8", { fatal: true }).decode(value);
|
|
3403
|
+
return true;
|
|
3404
|
+
} catch {
|
|
3405
|
+
return false;
|
|
3406
|
+
}
|
|
3407
|
+
} else {
|
|
3408
|
+
return false;
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3234
3412
|
function decodeTextRemovingBOM(value, encoding) {
|
|
3235
3413
|
return decode(value, encoding, false);
|
|
3236
3414
|
}
|
|
@@ -4520,6 +4698,7 @@ const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched loca
|
|
|
4520
4698
|
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
|
|
4521
4699
|
const MAX_KNOWN_VERSION = 63;
|
|
4522
4700
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4701
|
+
const PARENT_DIRECTORY_REGEXP = /(^|[\\/])\.\.([\\/]|$)/;
|
|
4523
4702
|
const CHARSET_UTF8 = "utf-8";
|
|
4524
4703
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4525
4704
|
const CHARSET_CP437 = "cp437";
|
|
@@ -4554,7 +4733,7 @@ class ZipReader {
|
|
|
4554
4733
|
Object.assign(this, {
|
|
4555
4734
|
reader: new GenericReader(reader),
|
|
4556
4735
|
options,
|
|
4557
|
-
readRanges: new
|
|
4736
|
+
readRanges: { indexes: new Set(), sortedRanges: [], pendingRanges: [] }
|
|
4558
4737
|
});
|
|
4559
4738
|
}
|
|
4560
4739
|
|
|
@@ -4772,12 +4951,13 @@ class ZipReader {
|
|
|
4772
4951
|
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4773
4952
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4774
4953
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4775
|
-
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4776
4954
|
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4777
4955
|
const endOffset = commentOffset + commentLength;
|
|
4778
|
-
const
|
|
4779
|
-
const
|
|
4780
|
-
const
|
|
4956
|
+
const rawEntryData = new Uint8Array(directoryArray.subarray(filenameOffset, endOffset));
|
|
4957
|
+
const rawFilename = rawEntryData.subarray(0, fileEntry.filenameLength);
|
|
4958
|
+
const rawComment = rawEntryData.subarray(fileEntry.filenameLength + fileEntry.extraFieldLength);
|
|
4959
|
+
const filenameUTF8 = languageEncodingFlag || (!filenameEncoding && isUTF8Text(rawFilename));
|
|
4960
|
+
const commentUTF8 = languageEncodingFlag || (!commentEncoding && isUTF8Text(rawComment));
|
|
4781
4961
|
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4782
4962
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4783
4963
|
const msdosAttributes = {
|
|
@@ -4828,7 +5008,7 @@ class ZipReader {
|
|
|
4828
5008
|
rawFilename,
|
|
4829
5009
|
filenameUTF8,
|
|
4830
5010
|
commentUTF8,
|
|
4831
|
-
rawExtraField:
|
|
5011
|
+
rawExtraField: rawEntryData.subarray(fileEntry.filenameLength, fileEntry.filenameLength + fileEntry.extraFieldLength),
|
|
4832
5012
|
rawComment,
|
|
4833
5013
|
filename,
|
|
4834
5014
|
comment
|
|
@@ -5199,7 +5379,6 @@ class ZipEntry {
|
|
|
5199
5379
|
throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
|
|
5200
5380
|
}
|
|
5201
5381
|
const size = compressedSize;
|
|
5202
|
-
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5203
5382
|
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5204
5383
|
throwIfAborted(signal);
|
|
5205
5384
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
@@ -5273,6 +5452,7 @@ class ZipEntry {
|
|
|
5273
5452
|
writer = new GenericWriter(writer);
|
|
5274
5453
|
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5275
5454
|
({ writable } = writer);
|
|
5455
|
+
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5276
5456
|
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5277
5457
|
if (writtenSize != outputSize) {
|
|
5278
5458
|
throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
|
|
@@ -5336,7 +5516,7 @@ function readDigitalSignature(signatureRecordArray) {
|
|
|
5336
5516
|
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5337
5517
|
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
5338
5518
|
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
5339
|
-
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
5519
|
+
return new Uint8Array(signatureRecordArray.subarray(6, 6 + signatureDataLength));
|
|
5340
5520
|
}
|
|
5341
5521
|
}
|
|
5342
5522
|
}
|
|
@@ -5708,14 +5888,61 @@ async function detectOverlappingEntry({
|
|
|
5708
5888
|
end: dataOffset + compressedSize + dataDescriptorLength,
|
|
5709
5889
|
fileEntry
|
|
5710
5890
|
};
|
|
5711
|
-
|
|
5712
|
-
|
|
5891
|
+
const { indexes, sortedRanges, pendingRanges } = readRanges;
|
|
5892
|
+
if (!indexes.has(index)) {
|
|
5893
|
+
const overlappingRange = findOverlappingRange(sortedRanges, range) || pendingRanges.find(otherRange => rangesOverlap(range, otherRange));
|
|
5894
|
+
if (overlappingRange) {
|
|
5713
5895
|
const error = new Error(ERR_OVERLAPPING_ENTRY);
|
|
5714
|
-
error.overlappingEntry =
|
|
5896
|
+
error.overlappingEntry = overlappingRange.fileEntry;
|
|
5715
5897
|
throw error;
|
|
5716
5898
|
}
|
|
5899
|
+
indexes.add(index);
|
|
5900
|
+
pendingRanges.push(range);
|
|
5901
|
+
if (pendingRanges.length * pendingRanges.length > sortedRanges.length) {
|
|
5902
|
+
pendingRanges.sort((range, otherRange) => range.start - otherRange.start);
|
|
5903
|
+
readRanges.sortedRanges = mergeRanges(sortedRanges, pendingRanges);
|
|
5904
|
+
pendingRanges.length = 0;
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
}
|
|
5908
|
+
|
|
5909
|
+
function findOverlappingRange(sortedRanges, range) {
|
|
5910
|
+
let low = 0;
|
|
5911
|
+
let high = sortedRanges.length;
|
|
5912
|
+
while (low < high) {
|
|
5913
|
+
const middle = (low + high) >>> 1;
|
|
5914
|
+
if (sortedRanges[middle].start < range.start) {
|
|
5915
|
+
low = middle + 1;
|
|
5916
|
+
} else {
|
|
5917
|
+
high = middle;
|
|
5918
|
+
}
|
|
5919
|
+
}
|
|
5920
|
+
const previousRange = sortedRanges[low - 1];
|
|
5921
|
+
const nextRange = sortedRanges[low];
|
|
5922
|
+
if (previousRange && rangesOverlap(range, previousRange)) {
|
|
5923
|
+
return previousRange;
|
|
5924
|
+
}
|
|
5925
|
+
if (nextRange && rangesOverlap(range, nextRange)) {
|
|
5926
|
+
return nextRange;
|
|
5927
|
+
}
|
|
5928
|
+
}
|
|
5929
|
+
|
|
5930
|
+
function rangesOverlap(range, otherRange) {
|
|
5931
|
+
return range.start < otherRange.end && otherRange.start < range.end;
|
|
5932
|
+
}
|
|
5933
|
+
|
|
5934
|
+
function mergeRanges(sortedRanges, pendingRanges) {
|
|
5935
|
+
const mergedRanges = [];
|
|
5936
|
+
let indexSorted = 0;
|
|
5937
|
+
let indexPending = 0;
|
|
5938
|
+
while (indexSorted < sortedRanges.length || indexPending < pendingRanges.length) {
|
|
5939
|
+
if (indexPending == pendingRanges.length || (indexSorted < sortedRanges.length && sortedRanges[indexSorted].start < pendingRanges[indexPending].start)) {
|
|
5940
|
+
mergedRanges.push(sortedRanges[indexSorted++]);
|
|
5941
|
+
} else {
|
|
5942
|
+
mergedRanges.push(pendingRanges[indexPending++]);
|
|
5943
|
+
}
|
|
5717
5944
|
}
|
|
5718
|
-
|
|
5945
|
+
return mergedRanges;
|
|
5719
5946
|
}
|
|
5720
5947
|
|
|
5721
5948
|
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
@@ -5812,10 +6039,10 @@ function isUnsafeFilename(filename, filenameValidation) {
|
|
|
5812
6039
|
if (pathParts.length > 1 && pathParts[pathParts.length - 1] === "") {
|
|
5813
6040
|
pathParts.pop();
|
|
5814
6041
|
}
|
|
5815
|
-
if (
|
|
6042
|
+
if (PARENT_DIRECTORY_REGEXP.test(filename) || filename.startsWith("/") || filename.startsWith("\\") || DRIVE_LETTER_REGEXP.test(filename)) {
|
|
5816
6043
|
return true;
|
|
5817
6044
|
}
|
|
5818
|
-
return filenameValidation == STRICTNESS_STRICT && (pathParts.includes(".") || pathParts.includes(""));
|
|
6045
|
+
return filenameValidation == STRICTNESS_STRICT && (pathParts.includes(".") || pathParts.includes("") || filename.includes("\0"));
|
|
5819
6046
|
}
|
|
5820
6047
|
|
|
5821
6048
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
@@ -5901,7 +6128,7 @@ async function* scanEndOfCentralDirectory(reader, scanLength) {
|
|
|
5901
6128
|
}
|
|
5902
6129
|
|
|
5903
6130
|
function getEndOfCentralDirectoryInfo(scanArray, indexByte, offset) {
|
|
5904
|
-
return { offset, buffer: scanArray.
|
|
6131
|
+
return { offset, buffer: new Uint8Array(scanArray.subarray(indexByte, indexByte + END_OF_CENTRAL_DIR_LENGTH)).buffer };
|
|
5905
6132
|
}
|
|
5906
6133
|
|
|
5907
6134
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
@@ -8548,7 +8775,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8548
8775
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8549
8776
|
*/
|
|
8550
8777
|
|
|
8551
|
-
const VERSION = "2.
|
|
8778
|
+
const VERSION = "2.15.0";
|
|
8552
8779
|
|
|
8553
8780
|
/*
|
|
8554
8781
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9071,7 +9298,6 @@ function _make(isCompress, type, options = {}) {
|
|
|
9071
9298
|
if (!this.out || !this.in) {
|
|
9072
9299
|
throw new Error("allocation failed");
|
|
9073
9300
|
}
|
|
9074
|
-
this._scratch = new Uint8Array(outBufferSize);
|
|
9075
9301
|
if (isCompress) {
|
|
9076
9302
|
this._process = wasm$1.deflate_process;
|
|
9077
9303
|
this._last_consumed = wasm$1.deflate_last_consumed;
|
|
@@ -9120,7 +9346,6 @@ function _make(isCompress, type, options = {}) {
|
|
|
9120
9346
|
const process = this._process;
|
|
9121
9347
|
const last_consumed = this._last_consumed;
|
|
9122
9348
|
const out = this.out;
|
|
9123
|
-
const scratch = this._scratch;
|
|
9124
9349
|
let offset = 0;
|
|
9125
9350
|
while (offset < buffer.length) {
|
|
9126
9351
|
const toRead = Math.min(buffer.length - offset, 32 * 1024);
|
|
@@ -9145,8 +9370,7 @@ function _make(isCompress, type, options = {}) {
|
|
|
9145
9370
|
}
|
|
9146
9371
|
const prod = result & 0x00ffffff;
|
|
9147
9372
|
if (prod) {
|
|
9148
|
-
|
|
9149
|
-
controller.enqueue(scratch.slice(0, prod));
|
|
9373
|
+
controller.enqueue(heap.slice(out, out + prod));
|
|
9150
9374
|
}
|
|
9151
9375
|
const consumed = last_consumed(this.streamHandle);
|
|
9152
9376
|
if (consumed === 0 && prod === 0) {
|
|
@@ -9164,7 +9388,6 @@ function _make(isCompress, type, options = {}) {
|
|
|
9164
9388
|
const heap = new Uint8Array(memory.buffer);
|
|
9165
9389
|
const process = this._process;
|
|
9166
9390
|
const out = this.out;
|
|
9167
|
-
const scratch = this._scratch;
|
|
9168
9391
|
while (true) {
|
|
9169
9392
|
const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9170
9393
|
const code = (result >> 24) & 0xff;
|
|
@@ -9174,8 +9397,7 @@ function _make(isCompress, type, options = {}) {
|
|
|
9174
9397
|
}
|
|
9175
9398
|
const produced = result & 0x00ffffff;
|
|
9176
9399
|
if (produced) {
|
|
9177
|
-
|
|
9178
|
-
controller.enqueue(scratch.slice(0, produced));
|
|
9400
|
+
controller.enqueue(heap.slice(out, out + produced));
|
|
9179
9401
|
}
|
|
9180
9402
|
if (code === 1 || produced === 0) {
|
|
9181
9403
|
break;
|