@zip.js/zip.js 2.8.55 → 2.8.57
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/deno.json +1 -1
- package/dist/zip-core-external.js +90 -52
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +90 -51
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +102 -60
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +101 -59
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +102 -60
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +102 -59
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +102 -59
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +90 -51
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +90 -51
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +90 -51
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +102 -59
- package/index-native.min.js +1 -1
- package/index.cjs +102 -59
- package/index.d.cts +18 -1
- package/index.d.ts +18 -1
- package/index.min.js +1 -1
- package/lib/core/options.js +14 -0
- package/lib/core/zip-fs.js +1 -1
- package/lib/core/zip-reader.js +19 -5
- package/lib/core/zip-writer.js +73 -55
- package/lib/zip-core-reader.js +1 -0
- package/package.json +1 -1
package/dist/zip-core.js
CHANGED
|
@@ -235,6 +235,18 @@
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
function checkInteger(value, maxValue, errorMessage) {
|
|
239
|
+
if (!Number.isInteger(value) || value < 0 || value > maxValue) {
|
|
240
|
+
throw new Error(errorMessage);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function checkIntegerOption(value, maxValue, errorMessage) {
|
|
245
|
+
if (value !== UNDEFINED_VALUE) {
|
|
246
|
+
checkInteger(value, maxValue, errorMessage);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
238
250
|
function toNumber(value) {
|
|
239
251
|
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
240
252
|
}
|
|
@@ -4695,6 +4707,7 @@
|
|
|
4695
4707
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4696
4708
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4697
4709
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4710
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4698
4711
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4699
4712
|
const CHARSET_UTF8 = "utf-8";
|
|
4700
4713
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4717,6 +4730,7 @@
|
|
|
4717
4730
|
bytes: 8
|
|
4718
4731
|
}
|
|
4719
4732
|
};
|
|
4733
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4720
4734
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4721
4735
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4722
4736
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4812,7 +4826,7 @@
|
|
|
4812
4826
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4813
4827
|
if (zip64EndOfDirectoryVersion2) {
|
|
4814
4828
|
const extensibleDataLength = Math.min(
|
|
4815
|
-
|
|
4829
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4816
4830
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4817
4831
|
if (extensibleDataLength > 0) {
|
|
4818
4832
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -5045,8 +5059,15 @@
|
|
|
5045
5059
|
yield entry;
|
|
5046
5060
|
}
|
|
5047
5061
|
let offsetAfterSignature = offset;
|
|
5048
|
-
|
|
5062
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5049
5063
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5064
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5065
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5066
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5067
|
+
if (signatureRecordLength >= 6) {
|
|
5068
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5050
5071
|
if (digitalSignature) {
|
|
5051
5072
|
zipReader.digitalSignature = digitalSignature;
|
|
5052
5073
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -5386,8 +5407,8 @@
|
|
|
5386
5407
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5387
5408
|
Object.assign(directoryEncryptionInfo, {
|
|
5388
5409
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5389
|
-
compressedSize:
|
|
5390
|
-
uncompressedSize:
|
|
5410
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
5411
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
5391
5412
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5392
5413
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5393
5414
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -6022,7 +6043,11 @@
|
|
|
6022
6043
|
}
|
|
6023
6044
|
|
|
6024
6045
|
function getBigUint64(view, offset) {
|
|
6025
|
-
|
|
6046
|
+
const value = view.getBigUint64(offset, true);
|
|
6047
|
+
if (value > MAX_SAFE_UINT64) {
|
|
6048
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
6049
|
+
}
|
|
6050
|
+
return Number(value);
|
|
6026
6051
|
}
|
|
6027
6052
|
|
|
6028
6053
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -6051,6 +6076,7 @@
|
|
|
6051
6076
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
6052
6077
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
6053
6078
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6079
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6054
6080
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6055
6081
|
ZipReader: ZipReader,
|
|
6056
6082
|
ZipReaderStream: ZipReaderStream
|
|
@@ -6123,6 +6149,8 @@
|
|
|
6123
6149
|
|
|
6124
6150
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6125
6151
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6152
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6153
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6126
6154
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6127
6155
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6128
6156
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6169,16 +6197,14 @@
|
|
|
6169
6197
|
await zipReader$1.close();
|
|
6170
6198
|
await initStream(this.writer);
|
|
6171
6199
|
const { directoryOffset } = zipReader$1;
|
|
6172
|
-
let splitZipSignatureLength = 0;
|
|
6173
6200
|
if (this.addSplitZipSignature) {
|
|
6174
6201
|
delete this.addSplitZipSignature;
|
|
6175
6202
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6176
6203
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6177
|
-
|
|
6178
|
-
this.offset += splitZipSignatureLength;
|
|
6204
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6179
6205
|
}
|
|
6180
6206
|
}
|
|
6181
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6207
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6182
6208
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6183
6209
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6184
6210
|
const {
|
|
@@ -6191,7 +6217,7 @@
|
|
|
6191
6217
|
encrypted,
|
|
6192
6218
|
uncompressedSize,
|
|
6193
6219
|
compressedSize,
|
|
6194
|
-
|
|
6220
|
+
extraFieldZip64
|
|
6195
6221
|
} = entry;
|
|
6196
6222
|
let {
|
|
6197
6223
|
compressionMethod,
|
|
@@ -6208,13 +6234,13 @@
|
|
|
6208
6234
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
6209
6235
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
6210
6236
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
6211
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
6237
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
6212
6238
|
if (entry.extraFieldAES) {
|
|
6213
6239
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6214
6240
|
}
|
|
6215
6241
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
6216
|
-
const zip64UncompressedSize =
|
|
6217
|
-
const zip64CompressedSize =
|
|
6242
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
6243
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
6218
6244
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
6219
6245
|
const {
|
|
6220
6246
|
headerArray,
|
|
@@ -6420,7 +6446,8 @@
|
|
|
6420
6446
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6421
6447
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6422
6448
|
offset: zipWriter.offset - diskOffset,
|
|
6423
|
-
diskNumberStart: diskNumber
|
|
6449
|
+
diskNumberStart: diskNumber,
|
|
6450
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6424
6451
|
});
|
|
6425
6452
|
const headerInfo = getHeaderInfo(options);
|
|
6426
6453
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6452,15 +6479,9 @@
|
|
|
6452
6479
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6453
6480
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6454
6481
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6459
|
-
throw new Error(ERR_INVALID_GID);
|
|
6460
|
-
}
|
|
6461
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6462
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6463
|
-
}
|
|
6482
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6483
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6484
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6464
6485
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6465
6486
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6466
6487
|
}
|
|
@@ -6482,9 +6503,7 @@
|
|
|
6482
6503
|
msDosCompatible = true;
|
|
6483
6504
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6484
6505
|
}
|
|
6485
|
-
|
|
6486
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6487
|
-
}
|
|
6506
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6488
6507
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6489
6508
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6490
6509
|
}
|
|
@@ -6624,9 +6643,7 @@
|
|
|
6624
6643
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6625
6644
|
}
|
|
6626
6645
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6627
|
-
|
|
6628
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6629
|
-
}
|
|
6646
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6630
6647
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6631
6648
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6632
6649
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6704,9 +6721,7 @@
|
|
|
6704
6721
|
let extraFieldSize = 0;
|
|
6705
6722
|
let offset = 0;
|
|
6706
6723
|
extraField.forEach((data, type) => {
|
|
6707
|
-
|
|
6708
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6709
|
-
}
|
|
6724
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6710
6725
|
if (!(data instanceof Uint8Array)) {
|
|
6711
6726
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6712
6727
|
}
|
|
@@ -6781,6 +6796,10 @@
|
|
|
6781
6796
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6782
6797
|
}
|
|
6783
6798
|
}
|
|
6799
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6800
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6801
|
+
dataDescriptor = false;
|
|
6802
|
+
}
|
|
6784
6803
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6785
6804
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6786
6805
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6795,6 +6814,7 @@
|
|
|
6795
6814
|
maximumCompressedSize,
|
|
6796
6815
|
resolvedOptions: {
|
|
6797
6816
|
dataDescriptor,
|
|
6817
|
+
emptyEntry,
|
|
6798
6818
|
zip64,
|
|
6799
6819
|
zip64UncompressedSize,
|
|
6800
6820
|
zip64CompressedSize,
|
|
@@ -6814,6 +6834,7 @@
|
|
|
6814
6834
|
const {
|
|
6815
6835
|
keepOrder,
|
|
6816
6836
|
dataDescriptor,
|
|
6837
|
+
emptyEntry,
|
|
6817
6838
|
signal
|
|
6818
6839
|
} = options;
|
|
6819
6840
|
const {
|
|
@@ -6838,7 +6859,7 @@
|
|
|
6838
6859
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6839
6860
|
requestLockCurrentFileEntry();
|
|
6840
6861
|
}
|
|
6841
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6862
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6842
6863
|
bufferedWrite = true;
|
|
6843
6864
|
zipWriter.bufferedWrites++;
|
|
6844
6865
|
if (options.createTempStream) {
|
|
@@ -7260,8 +7281,8 @@
|
|
|
7260
7281
|
try {
|
|
7261
7282
|
const { uid, gid, unixExtraFieldType } = options;
|
|
7262
7283
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7263
|
-
const uidBytes = packUnixId(uid);
|
|
7264
|
-
const gidBytes = packUnixId(gid);
|
|
7284
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
7285
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
7265
7286
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7266
7287
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7267
7288
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -7300,12 +7321,13 @@
|
|
|
7300
7321
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7301
7322
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7302
7323
|
}
|
|
7303
|
-
rawExtraFieldAES
|
|
7324
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7304
7325
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7305
7326
|
}
|
|
7306
7327
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7307
7328
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7308
|
-
|
|
7329
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7330
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7309
7331
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7310
7332
|
}
|
|
7311
7333
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7391,18 +7413,14 @@
|
|
|
7391
7413
|
}
|
|
7392
7414
|
|
|
7393
7415
|
function packUnixId(id) {
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
let length = 4;
|
|
7401
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7402
|
-
length--;
|
|
7403
|
-
}
|
|
7404
|
-
return dataArray.subarray(0, length);
|
|
7416
|
+
const dataArray = new Uint8Array(4);
|
|
7417
|
+
const dataView = getDataView(dataArray);
|
|
7418
|
+
dataView.setUint32(0, id, true);
|
|
7419
|
+
let length = 4;
|
|
7420
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7421
|
+
length--;
|
|
7405
7422
|
}
|
|
7423
|
+
return dataArray.subarray(0, length);
|
|
7406
7424
|
}
|
|
7407
7425
|
|
|
7408
7426
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7706,7 +7724,11 @@
|
|
|
7706
7724
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7707
7725
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7708
7726
|
signatureRecord.writeBytes(signatureData);
|
|
7709
|
-
|
|
7727
|
+
const { writer } = zipWriter;
|
|
7728
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7729
|
+
await writer.closeDisk();
|
|
7730
|
+
}
|
|
7731
|
+
await writeData(writer, signatureRecord.array);
|
|
7710
7732
|
return 6 + signatureDataLength;
|
|
7711
7733
|
}
|
|
7712
7734
|
return 0;
|
|
@@ -7817,7 +7839,22 @@
|
|
|
7817
7839
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7818
7840
|
}
|
|
7819
7841
|
|
|
7820
|
-
|
|
7842
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7843
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7844
|
+
let offsetExtraField = 0;
|
|
7845
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7846
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7847
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7848
|
+
return removeExtraFieldZip64(concat(
|
|
7849
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7850
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7851
|
+
}
|
|
7852
|
+
offsetExtraField += size;
|
|
7853
|
+
}
|
|
7854
|
+
return rawExtraField;
|
|
7855
|
+
}
|
|
7856
|
+
|
|
7857
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7821
7858
|
const { writer } = zipWriter;
|
|
7822
7859
|
const entryPositions = new Map();
|
|
7823
7860
|
if (writer.closeDisk) {
|
|
@@ -7838,9 +7875,10 @@
|
|
|
7838
7875
|
}
|
|
7839
7876
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7840
7877
|
} else {
|
|
7878
|
+
const baseOffset = zipWriter.offset;
|
|
7841
7879
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7842
7880
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7843
|
-
offset:
|
|
7881
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7844
7882
|
diskNumberStart: 0
|
|
7845
7883
|
}));
|
|
7846
7884
|
}
|
|
@@ -8624,6 +8662,7 @@
|
|
|
8624
8662
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
8625
8663
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
8626
8664
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
8665
|
+
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
8627
8666
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
8628
8667
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
8629
8668
|
exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
|