@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
|
}
|
|
@@ -4540,6 +4718,7 @@ const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched loca
|
|
|
4540
4718
|
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
|
|
4541
4719
|
const MAX_KNOWN_VERSION = 63;
|
|
4542
4720
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4721
|
+
const PARENT_DIRECTORY_REGEXP = /(^|[\\/])\.\.([\\/]|$)/;
|
|
4543
4722
|
const CHARSET_UTF8 = "utf-8";
|
|
4544
4723
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
4545
4724
|
const CHARSET_CP437 = "cp437";
|
|
@@ -4574,7 +4753,7 @@ class ZipReader {
|
|
|
4574
4753
|
Object.assign(this, {
|
|
4575
4754
|
reader: new GenericReader(reader),
|
|
4576
4755
|
options,
|
|
4577
|
-
readRanges: new
|
|
4756
|
+
readRanges: { indexes: new Set(), sortedRanges: [], pendingRanges: [] }
|
|
4578
4757
|
});
|
|
4579
4758
|
}
|
|
4580
4759
|
|
|
@@ -4792,12 +4971,13 @@ class ZipReader {
|
|
|
4792
4971
|
const versionMadeBy = getUint16$1(directoryView, offset + 4);
|
|
4793
4972
|
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
4794
4973
|
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
4795
|
-
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
4796
4974
|
const commentLength = getUint16$1(directoryView, offset + 32);
|
|
4797
4975
|
const endOffset = commentOffset + commentLength;
|
|
4798
|
-
const
|
|
4799
|
-
const
|
|
4800
|
-
const
|
|
4976
|
+
const rawEntryData = new Uint8Array(directoryArray.subarray(filenameOffset, endOffset));
|
|
4977
|
+
const rawFilename = rawEntryData.subarray(0, fileEntry.filenameLength);
|
|
4978
|
+
const rawComment = rawEntryData.subarray(fileEntry.filenameLength + fileEntry.extraFieldLength);
|
|
4979
|
+
const filenameUTF8 = languageEncodingFlag || (!filenameEncoding && isUTF8Text(rawFilename));
|
|
4980
|
+
const commentUTF8 = languageEncodingFlag || (!commentEncoding && isUTF8Text(rawComment));
|
|
4801
4981
|
const externalFileAttributes = getUint32$1(directoryView, offset + 38);
|
|
4802
4982
|
const msdosAttributesRaw = externalFileAttributes & MAX_8_BITS;
|
|
4803
4983
|
const msdosAttributes = {
|
|
@@ -4848,7 +5028,7 @@ class ZipReader {
|
|
|
4848
5028
|
rawFilename,
|
|
4849
5029
|
filenameUTF8,
|
|
4850
5030
|
commentUTF8,
|
|
4851
|
-
rawExtraField:
|
|
5031
|
+
rawExtraField: rawEntryData.subarray(fileEntry.filenameLength, fileEntry.filenameLength + fileEntry.extraFieldLength),
|
|
4852
5032
|
rawComment,
|
|
4853
5033
|
filename,
|
|
4854
5034
|
comment
|
|
@@ -5219,7 +5399,6 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5219
5399
|
throw new Error(ERR_ENTRY_DATA_OUT_OF_BOUNDS);
|
|
5220
5400
|
}
|
|
5221
5401
|
const size = compressedSize;
|
|
5222
|
-
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5223
5402
|
const signal = checkSignalOption(getOptionValue$1(zipEntry, options, OPTION_SIGNAL));
|
|
5224
5403
|
throwIfAborted(signal);
|
|
5225
5404
|
let checkOverlappingEntry = getOptionValue$1(zipEntry, options, OPTION_CHECK_OVERLAPPING_ENTRY);
|
|
@@ -5293,6 +5472,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5293
5472
|
writer = new GenericWriter(writer);
|
|
5294
5473
|
await initStream(writer, getDecodableOutputSize(outputSize, compressedSize, compressed));
|
|
5295
5474
|
({ writable } = writer);
|
|
5475
|
+
const readable = toCompatibleReadable(reader.createReadable({ offset: dataOffset, size }));
|
|
5296
5476
|
const { outputSize: writtenSize } = await runWorker({ readable, writable }, workerOptions);
|
|
5297
5477
|
if (writtenSize != outputSize) {
|
|
5298
5478
|
throw Object.assign(new Error(ERR_INVALID_UNCOMPRESSED_SIZE), { outputSize: writtenSize });
|
|
@@ -5356,7 +5536,7 @@ function readDigitalSignature(signatureRecordArray) {
|
|
|
5356
5536
|
if (getUint32$1(signatureRecordView, 0) == DIGITAL_SIGNATURE_RECORD_SIGNATURE) {
|
|
5357
5537
|
const signatureDataLength = getUint16$1(signatureRecordView, 4);
|
|
5358
5538
|
if (6 + signatureDataLength <= signatureRecordArray.length) {
|
|
5359
|
-
return signatureRecordArray.subarray(6, 6 + signatureDataLength);
|
|
5539
|
+
return new Uint8Array(signatureRecordArray.subarray(6, 6 + signatureDataLength));
|
|
5360
5540
|
}
|
|
5361
5541
|
}
|
|
5362
5542
|
}
|
|
@@ -5728,14 +5908,61 @@ async function detectOverlappingEntry({
|
|
|
5728
5908
|
end: dataOffset + compressedSize + dataDescriptorLength,
|
|
5729
5909
|
fileEntry
|
|
5730
5910
|
};
|
|
5731
|
-
|
|
5732
|
-
|
|
5911
|
+
const { indexes, sortedRanges, pendingRanges } = readRanges;
|
|
5912
|
+
if (!indexes.has(index)) {
|
|
5913
|
+
const overlappingRange = findOverlappingRange(sortedRanges, range) || pendingRanges.find(otherRange => rangesOverlap(range, otherRange));
|
|
5914
|
+
if (overlappingRange) {
|
|
5733
5915
|
const error = new Error(ERR_OVERLAPPING_ENTRY);
|
|
5734
|
-
error.overlappingEntry =
|
|
5916
|
+
error.overlappingEntry = overlappingRange.fileEntry;
|
|
5735
5917
|
throw error;
|
|
5736
5918
|
}
|
|
5919
|
+
indexes.add(index);
|
|
5920
|
+
pendingRanges.push(range);
|
|
5921
|
+
if (pendingRanges.length * pendingRanges.length > sortedRanges.length) {
|
|
5922
|
+
pendingRanges.sort((range, otherRange) => range.start - otherRange.start);
|
|
5923
|
+
readRanges.sortedRanges = mergeRanges(sortedRanges, pendingRanges);
|
|
5924
|
+
pendingRanges.length = 0;
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
}
|
|
5928
|
+
|
|
5929
|
+
function findOverlappingRange(sortedRanges, range) {
|
|
5930
|
+
let low = 0;
|
|
5931
|
+
let high = sortedRanges.length;
|
|
5932
|
+
while (low < high) {
|
|
5933
|
+
const middle = (low + high) >>> 1;
|
|
5934
|
+
if (sortedRanges[middle].start < range.start) {
|
|
5935
|
+
low = middle + 1;
|
|
5936
|
+
} else {
|
|
5937
|
+
high = middle;
|
|
5938
|
+
}
|
|
5939
|
+
}
|
|
5940
|
+
const previousRange = sortedRanges[low - 1];
|
|
5941
|
+
const nextRange = sortedRanges[low];
|
|
5942
|
+
if (previousRange && rangesOverlap(range, previousRange)) {
|
|
5943
|
+
return previousRange;
|
|
5944
|
+
}
|
|
5945
|
+
if (nextRange && rangesOverlap(range, nextRange)) {
|
|
5946
|
+
return nextRange;
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5949
|
+
|
|
5950
|
+
function rangesOverlap(range, otherRange) {
|
|
5951
|
+
return range.start < otherRange.end && otherRange.start < range.end;
|
|
5952
|
+
}
|
|
5953
|
+
|
|
5954
|
+
function mergeRanges(sortedRanges, pendingRanges) {
|
|
5955
|
+
const mergedRanges = [];
|
|
5956
|
+
let indexSorted = 0;
|
|
5957
|
+
let indexPending = 0;
|
|
5958
|
+
while (indexSorted < sortedRanges.length || indexPending < pendingRanges.length) {
|
|
5959
|
+
if (indexPending == pendingRanges.length || (indexSorted < sortedRanges.length && sortedRanges[indexSorted].start < pendingRanges[indexPending].start)) {
|
|
5960
|
+
mergedRanges.push(sortedRanges[indexSorted++]);
|
|
5961
|
+
} else {
|
|
5962
|
+
mergedRanges.push(pendingRanges[indexPending++]);
|
|
5963
|
+
}
|
|
5737
5964
|
}
|
|
5738
|
-
|
|
5965
|
+
return mergedRanges;
|
|
5739
5966
|
}
|
|
5740
5967
|
|
|
5741
5968
|
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
@@ -5832,10 +6059,10 @@ function isUnsafeFilename(filename, filenameValidation) {
|
|
|
5832
6059
|
if (pathParts.length > 1 && pathParts[pathParts.length - 1] === "") {
|
|
5833
6060
|
pathParts.pop();
|
|
5834
6061
|
}
|
|
5835
|
-
if (
|
|
6062
|
+
if (PARENT_DIRECTORY_REGEXP.test(filename) || filename.startsWith("/") || filename.startsWith("\\") || DRIVE_LETTER_REGEXP.test(filename)) {
|
|
5836
6063
|
return true;
|
|
5837
6064
|
}
|
|
5838
|
-
return filenameValidation == STRICTNESS_STRICT && (pathParts.includes(".") || pathParts.includes(""));
|
|
6065
|
+
return filenameValidation == STRICTNESS_STRICT && (pathParts.includes(".") || pathParts.includes("") || filename.includes("\0"));
|
|
5839
6066
|
}
|
|
5840
6067
|
|
|
5841
6068
|
function getMaxAppendedDataSize(maxAppendedDataSize, strictness) {
|
|
@@ -5921,7 +6148,7 @@ async function* scanEndOfCentralDirectory(reader, scanLength) {
|
|
|
5921
6148
|
}
|
|
5922
6149
|
|
|
5923
6150
|
function getEndOfCentralDirectoryInfo(scanArray, indexByte, offset) {
|
|
5924
|
-
return { offset, buffer: scanArray.
|
|
6151
|
+
return { offset, buffer: new Uint8Array(scanArray.subarray(indexByte, indexByte + END_OF_CENTRAL_DIR_LENGTH)).buffer };
|
|
5925
6152
|
}
|
|
5926
6153
|
|
|
5927
6154
|
async function getCentralDirectoryReachability(reader, view, anchoredOffset, indexByte, offset, size, remoteProbeBudget) {
|
|
@@ -8666,7 +8893,7 @@ function formatSupported(StreamClass, format) {
|
|
|
8666
8893
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
8667
8894
|
*/
|
|
8668
8895
|
|
|
8669
|
-
const VERSION = "2.
|
|
8896
|
+
const VERSION = "2.15.0";
|
|
8670
8897
|
|
|
8671
8898
|
/*
|
|
8672
8899
|
Copyright (c) 2025 Gildas Lormeau. All rights reserved.
|
|
@@ -9189,7 +9416,6 @@ function _make(isCompress, type, options = {}) {
|
|
|
9189
9416
|
if (!this.out || !this.in) {
|
|
9190
9417
|
throw new Error("allocation failed");
|
|
9191
9418
|
}
|
|
9192
|
-
this._scratch = new Uint8Array(outBufferSize);
|
|
9193
9419
|
if (isCompress) {
|
|
9194
9420
|
this._process = wasm$1.deflate_process;
|
|
9195
9421
|
this._last_consumed = wasm$1.deflate_last_consumed;
|
|
@@ -9238,7 +9464,6 @@ function _make(isCompress, type, options = {}) {
|
|
|
9238
9464
|
const process = this._process;
|
|
9239
9465
|
const last_consumed = this._last_consumed;
|
|
9240
9466
|
const out = this.out;
|
|
9241
|
-
const scratch = this._scratch;
|
|
9242
9467
|
let offset = 0;
|
|
9243
9468
|
while (offset < buffer.length) {
|
|
9244
9469
|
const toRead = Math.min(buffer.length - offset, 32 * 1024);
|
|
@@ -9263,8 +9488,7 @@ function _make(isCompress, type, options = {}) {
|
|
|
9263
9488
|
}
|
|
9264
9489
|
const prod = result & 0x00ffffff;
|
|
9265
9490
|
if (prod) {
|
|
9266
|
-
|
|
9267
|
-
controller.enqueue(scratch.slice(0, prod));
|
|
9491
|
+
controller.enqueue(heap.slice(out, out + prod));
|
|
9268
9492
|
}
|
|
9269
9493
|
const consumed = last_consumed(this.streamHandle);
|
|
9270
9494
|
if (consumed === 0 && prod === 0) {
|
|
@@ -9282,7 +9506,6 @@ function _make(isCompress, type, options = {}) {
|
|
|
9282
9506
|
const heap = new Uint8Array(memory.buffer);
|
|
9283
9507
|
const process = this._process;
|
|
9284
9508
|
const out = this.out;
|
|
9285
|
-
const scratch = this._scratch;
|
|
9286
9509
|
while (true) {
|
|
9287
9510
|
const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
|
|
9288
9511
|
const code = (result >> 24) & 0xff;
|
|
@@ -9292,8 +9515,7 @@ function _make(isCompress, type, options = {}) {
|
|
|
9292
9515
|
}
|
|
9293
9516
|
const produced = result & 0x00ffffff;
|
|
9294
9517
|
if (produced) {
|
|
9295
|
-
|
|
9296
|
-
controller.enqueue(scratch.slice(0, produced));
|
|
9518
|
+
controller.enqueue(heap.slice(out, out + produced));
|
|
9297
9519
|
}
|
|
9298
9520
|
if (code === 1 || produced === 0) {
|
|
9299
9521
|
break;
|