@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.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
|
}
|
|
@@ -4701,6 +4713,7 @@
|
|
|
4701
4713
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4702
4714
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4703
4715
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4716
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4704
4717
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4705
4718
|
const CHARSET_UTF8 = "utf-8";
|
|
4706
4719
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4723,6 +4736,7 @@
|
|
|
4723
4736
|
bytes: 8
|
|
4724
4737
|
}
|
|
4725
4738
|
};
|
|
4739
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4726
4740
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4727
4741
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4728
4742
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4818,7 +4832,7 @@
|
|
|
4818
4832
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4819
4833
|
if (zip64EndOfDirectoryVersion2) {
|
|
4820
4834
|
const extensibleDataLength = Math.min(
|
|
4821
|
-
|
|
4835
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4822
4836
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4823
4837
|
if (extensibleDataLength > 0) {
|
|
4824
4838
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -5051,8 +5065,15 @@
|
|
|
5051
5065
|
yield entry;
|
|
5052
5066
|
}
|
|
5053
5067
|
let offsetAfterSignature = offset;
|
|
5054
|
-
|
|
5068
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5055
5069
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5070
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5071
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5072
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5073
|
+
if (signatureRecordLength >= 6) {
|
|
5074
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5056
5077
|
if (digitalSignature) {
|
|
5057
5078
|
zipReader.digitalSignature = digitalSignature;
|
|
5058
5079
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -5392,8 +5413,8 @@
|
|
|
5392
5413
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5393
5414
|
Object.assign(directoryEncryptionInfo, {
|
|
5394
5415
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5395
|
-
compressedSize:
|
|
5396
|
-
uncompressedSize:
|
|
5416
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
5417
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
5397
5418
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5398
5419
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5399
5420
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -6028,7 +6049,11 @@
|
|
|
6028
6049
|
}
|
|
6029
6050
|
|
|
6030
6051
|
function getBigUint64(view, offset) {
|
|
6031
|
-
|
|
6052
|
+
const value = view.getBigUint64(offset, true);
|
|
6053
|
+
if (value > MAX_SAFE_UINT64) {
|
|
6054
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
6055
|
+
}
|
|
6056
|
+
return Number(value);
|
|
6032
6057
|
}
|
|
6033
6058
|
|
|
6034
6059
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -6057,6 +6082,7 @@
|
|
|
6057
6082
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
6058
6083
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
6059
6084
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6085
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6060
6086
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6061
6087
|
ZipReader: ZipReader,
|
|
6062
6088
|
ZipReaderStream: ZipReaderStream
|
|
@@ -6129,6 +6155,8 @@
|
|
|
6129
6155
|
|
|
6130
6156
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6131
6157
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6158
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6159
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6132
6160
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6133
6161
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6134
6162
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6175,16 +6203,14 @@
|
|
|
6175
6203
|
await zipReader$1.close();
|
|
6176
6204
|
await initStream(this.writer);
|
|
6177
6205
|
const { directoryOffset } = zipReader$1;
|
|
6178
|
-
let splitZipSignatureLength = 0;
|
|
6179
6206
|
if (this.addSplitZipSignature) {
|
|
6180
6207
|
delete this.addSplitZipSignature;
|
|
6181
6208
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6182
6209
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6183
|
-
|
|
6184
|
-
this.offset += splitZipSignatureLength;
|
|
6210
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6185
6211
|
}
|
|
6186
6212
|
}
|
|
6187
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6213
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6188
6214
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6189
6215
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6190
6216
|
const {
|
|
@@ -6197,7 +6223,7 @@
|
|
|
6197
6223
|
encrypted,
|
|
6198
6224
|
uncompressedSize,
|
|
6199
6225
|
compressedSize,
|
|
6200
|
-
|
|
6226
|
+
extraFieldZip64
|
|
6201
6227
|
} = entry;
|
|
6202
6228
|
let {
|
|
6203
6229
|
compressionMethod,
|
|
@@ -6214,13 +6240,13 @@
|
|
|
6214
6240
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
6215
6241
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
6216
6242
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
6217
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
6243
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
6218
6244
|
if (entry.extraFieldAES) {
|
|
6219
6245
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6220
6246
|
}
|
|
6221
6247
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
6222
|
-
const zip64UncompressedSize =
|
|
6223
|
-
const zip64CompressedSize =
|
|
6248
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
6249
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
6224
6250
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
6225
6251
|
const {
|
|
6226
6252
|
headerArray,
|
|
@@ -6426,7 +6452,8 @@
|
|
|
6426
6452
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6427
6453
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6428
6454
|
offset: zipWriter.offset - diskOffset,
|
|
6429
|
-
diskNumberStart: diskNumber
|
|
6455
|
+
diskNumberStart: diskNumber,
|
|
6456
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6430
6457
|
});
|
|
6431
6458
|
const headerInfo = getHeaderInfo(options);
|
|
6432
6459
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6458,15 +6485,9 @@
|
|
|
6458
6485
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6459
6486
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6460
6487
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6465
|
-
throw new Error(ERR_INVALID_GID);
|
|
6466
|
-
}
|
|
6467
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6468
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6469
|
-
}
|
|
6488
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6489
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6490
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6470
6491
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6471
6492
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6472
6493
|
}
|
|
@@ -6488,9 +6509,7 @@
|
|
|
6488
6509
|
msDosCompatible = true;
|
|
6489
6510
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6490
6511
|
}
|
|
6491
|
-
|
|
6492
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6493
|
-
}
|
|
6512
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6494
6513
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6495
6514
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6496
6515
|
}
|
|
@@ -6630,9 +6649,7 @@
|
|
|
6630
6649
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6631
6650
|
}
|
|
6632
6651
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6633
|
-
|
|
6634
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6635
|
-
}
|
|
6652
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6636
6653
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6637
6654
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6638
6655
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6710,9 +6727,7 @@
|
|
|
6710
6727
|
let extraFieldSize = 0;
|
|
6711
6728
|
let offset = 0;
|
|
6712
6729
|
extraField.forEach((data, type) => {
|
|
6713
|
-
|
|
6714
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6715
|
-
}
|
|
6730
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6716
6731
|
if (!(data instanceof Uint8Array)) {
|
|
6717
6732
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6718
6733
|
}
|
|
@@ -6787,6 +6802,10 @@
|
|
|
6787
6802
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6788
6803
|
}
|
|
6789
6804
|
}
|
|
6805
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6806
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6807
|
+
dataDescriptor = false;
|
|
6808
|
+
}
|
|
6790
6809
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6791
6810
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6792
6811
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6801,6 +6820,7 @@
|
|
|
6801
6820
|
maximumCompressedSize,
|
|
6802
6821
|
resolvedOptions: {
|
|
6803
6822
|
dataDescriptor,
|
|
6823
|
+
emptyEntry,
|
|
6804
6824
|
zip64,
|
|
6805
6825
|
zip64UncompressedSize,
|
|
6806
6826
|
zip64CompressedSize,
|
|
@@ -6820,6 +6840,7 @@
|
|
|
6820
6840
|
const {
|
|
6821
6841
|
keepOrder,
|
|
6822
6842
|
dataDescriptor,
|
|
6843
|
+
emptyEntry,
|
|
6823
6844
|
signal
|
|
6824
6845
|
} = options;
|
|
6825
6846
|
const {
|
|
@@ -6844,7 +6865,7 @@
|
|
|
6844
6865
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6845
6866
|
requestLockCurrentFileEntry();
|
|
6846
6867
|
}
|
|
6847
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6868
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6848
6869
|
bufferedWrite = true;
|
|
6849
6870
|
zipWriter.bufferedWrites++;
|
|
6850
6871
|
if (options.createTempStream) {
|
|
@@ -7266,8 +7287,8 @@
|
|
|
7266
7287
|
try {
|
|
7267
7288
|
const { uid, gid, unixExtraFieldType } = options;
|
|
7268
7289
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7269
|
-
const uidBytes = packUnixId(uid);
|
|
7270
|
-
const gidBytes = packUnixId(gid);
|
|
7290
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
7291
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
7271
7292
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7272
7293
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7273
7294
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -7306,12 +7327,13 @@
|
|
|
7306
7327
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7307
7328
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7308
7329
|
}
|
|
7309
|
-
rawExtraFieldAES
|
|
7330
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7310
7331
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7311
7332
|
}
|
|
7312
7333
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7313
7334
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7314
|
-
|
|
7335
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7336
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7315
7337
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7316
7338
|
}
|
|
7317
7339
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7397,18 +7419,14 @@
|
|
|
7397
7419
|
}
|
|
7398
7420
|
|
|
7399
7421
|
function packUnixId(id) {
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
let length = 4;
|
|
7407
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7408
|
-
length--;
|
|
7409
|
-
}
|
|
7410
|
-
return dataArray.subarray(0, length);
|
|
7422
|
+
const dataArray = new Uint8Array(4);
|
|
7423
|
+
const dataView = getDataView(dataArray);
|
|
7424
|
+
dataView.setUint32(0, id, true);
|
|
7425
|
+
let length = 4;
|
|
7426
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7427
|
+
length--;
|
|
7411
7428
|
}
|
|
7429
|
+
return dataArray.subarray(0, length);
|
|
7412
7430
|
}
|
|
7413
7431
|
|
|
7414
7432
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7712,7 +7730,11 @@
|
|
|
7712
7730
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7713
7731
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7714
7732
|
signatureRecord.writeBytes(signatureData);
|
|
7715
|
-
|
|
7733
|
+
const { writer } = zipWriter;
|
|
7734
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7735
|
+
await writer.closeDisk();
|
|
7736
|
+
}
|
|
7737
|
+
await writeData(writer, signatureRecord.array);
|
|
7716
7738
|
return 6 + signatureDataLength;
|
|
7717
7739
|
}
|
|
7718
7740
|
return 0;
|
|
@@ -7823,7 +7845,22 @@
|
|
|
7823
7845
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7824
7846
|
}
|
|
7825
7847
|
|
|
7826
|
-
|
|
7848
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7849
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7850
|
+
let offsetExtraField = 0;
|
|
7851
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7852
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7853
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7854
|
+
return removeExtraFieldZip64(concat(
|
|
7855
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7856
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7857
|
+
}
|
|
7858
|
+
offsetExtraField += size;
|
|
7859
|
+
}
|
|
7860
|
+
return rawExtraField;
|
|
7861
|
+
}
|
|
7862
|
+
|
|
7863
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7827
7864
|
const { writer } = zipWriter;
|
|
7828
7865
|
const entryPositions = new Map();
|
|
7829
7866
|
if (writer.closeDisk) {
|
|
@@ -7844,9 +7881,10 @@
|
|
|
7844
7881
|
}
|
|
7845
7882
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7846
7883
|
} else {
|
|
7884
|
+
const baseOffset = zipWriter.offset;
|
|
7847
7885
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7848
7886
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7849
|
-
offset:
|
|
7887
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7850
7888
|
diskNumberStart: 0
|
|
7851
7889
|
}));
|
|
7852
7890
|
}
|
|
@@ -9064,6 +9102,7 @@
|
|
|
9064
9102
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
9065
9103
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
9066
9104
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
9105
|
+
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
9067
9106
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
9068
9107
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
9069
9108
|
exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
|