@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-native.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
|
}
|
|
@@ -4697,6 +4709,7 @@
|
|
|
4697
4709
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4698
4710
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4699
4711
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4712
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4700
4713
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4701
4714
|
const CHARSET_UTF8 = "utf-8";
|
|
4702
4715
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4719,6 +4732,7 @@
|
|
|
4719
4732
|
bytes: 8
|
|
4720
4733
|
}
|
|
4721
4734
|
};
|
|
4735
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4722
4736
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4723
4737
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4724
4738
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4814,7 +4828,7 @@
|
|
|
4814
4828
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4815
4829
|
if (zip64EndOfDirectoryVersion2) {
|
|
4816
4830
|
const extensibleDataLength = Math.min(
|
|
4817
|
-
|
|
4831
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4818
4832
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4819
4833
|
if (extensibleDataLength > 0) {
|
|
4820
4834
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -5047,8 +5061,15 @@
|
|
|
5047
5061
|
yield entry;
|
|
5048
5062
|
}
|
|
5049
5063
|
let offsetAfterSignature = offset;
|
|
5050
|
-
|
|
5064
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
5051
5065
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
5066
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
5067
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
5068
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
5069
|
+
if (signatureRecordLength >= 6) {
|
|
5070
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5052
5073
|
if (digitalSignature) {
|
|
5053
5074
|
zipReader.digitalSignature = digitalSignature;
|
|
5054
5075
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -5388,8 +5409,8 @@
|
|
|
5388
5409
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
5389
5410
|
Object.assign(directoryEncryptionInfo, {
|
|
5390
5411
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
5391
|
-
compressedSize:
|
|
5392
|
-
uncompressedSize:
|
|
5412
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
5413
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
5393
5414
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
5394
5415
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
5395
5416
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -6024,7 +6045,11 @@
|
|
|
6024
6045
|
}
|
|
6025
6046
|
|
|
6026
6047
|
function getBigUint64(view, offset) {
|
|
6027
|
-
|
|
6048
|
+
const value = view.getBigUint64(offset, true);
|
|
6049
|
+
if (value > MAX_SAFE_UINT64) {
|
|
6050
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
6051
|
+
}
|
|
6052
|
+
return Number(value);
|
|
6028
6053
|
}
|
|
6029
6054
|
|
|
6030
6055
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -6053,6 +6078,7 @@
|
|
|
6053
6078
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
6054
6079
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
6055
6080
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6081
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6056
6082
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6057
6083
|
ZipReader: ZipReader,
|
|
6058
6084
|
ZipReaderStream: ZipReaderStream
|
|
@@ -6125,6 +6151,8 @@
|
|
|
6125
6151
|
|
|
6126
6152
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
6127
6153
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
6154
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
6155
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
6128
6156
|
const VENDOR_VERSION_AE_1 = 1;
|
|
6129
6157
|
const INFOZIP_EXTRA_FIELD_TYPE = "infozip";
|
|
6130
6158
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -6171,16 +6199,14 @@
|
|
|
6171
6199
|
await zipReader$1.close();
|
|
6172
6200
|
await initStream(this.writer);
|
|
6173
6201
|
const { directoryOffset } = zipReader$1;
|
|
6174
|
-
let splitZipSignatureLength = 0;
|
|
6175
6202
|
if (this.addSplitZipSignature) {
|
|
6176
6203
|
delete this.addSplitZipSignature;
|
|
6177
6204
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
6178
6205
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
6179
|
-
|
|
6180
|
-
this.offset += splitZipSignatureLength;
|
|
6206
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
6181
6207
|
}
|
|
6182
6208
|
}
|
|
6183
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
6209
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
6184
6210
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
6185
6211
|
this.fileEntries = new Map(entries.map(entry => {
|
|
6186
6212
|
const {
|
|
@@ -6193,7 +6219,7 @@
|
|
|
6193
6219
|
encrypted,
|
|
6194
6220
|
uncompressedSize,
|
|
6195
6221
|
compressedSize,
|
|
6196
|
-
|
|
6222
|
+
extraFieldZip64
|
|
6197
6223
|
} = entry;
|
|
6198
6224
|
let {
|
|
6199
6225
|
compressionMethod,
|
|
@@ -6210,13 +6236,13 @@
|
|
|
6210
6236
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
6211
6237
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
6212
6238
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
6213
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
6239
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
6214
6240
|
if (entry.extraFieldAES) {
|
|
6215
6241
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6216
6242
|
}
|
|
6217
6243
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
6218
|
-
const zip64UncompressedSize =
|
|
6219
|
-
const zip64CompressedSize =
|
|
6244
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
6245
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
6220
6246
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
6221
6247
|
const {
|
|
6222
6248
|
headerArray,
|
|
@@ -6422,7 +6448,8 @@
|
|
|
6422
6448
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6423
6449
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6424
6450
|
offset: zipWriter.offset - diskOffset,
|
|
6425
|
-
diskNumberStart: diskNumber
|
|
6451
|
+
diskNumberStart: diskNumber,
|
|
6452
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
6426
6453
|
});
|
|
6427
6454
|
const headerInfo = getHeaderInfo(options);
|
|
6428
6455
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -6454,15 +6481,9 @@
|
|
|
6454
6481
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
6455
6482
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
6456
6483
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
6461
|
-
throw new Error(ERR_INVALID_GID);
|
|
6462
|
-
}
|
|
6463
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
6464
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
6465
|
-
}
|
|
6484
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
6485
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
6486
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
6466
6487
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
6467
6488
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
6468
6489
|
}
|
|
@@ -6484,9 +6505,7 @@
|
|
|
6484
6505
|
msDosCompatible = true;
|
|
6485
6506
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
6486
6507
|
}
|
|
6487
|
-
|
|
6488
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6489
|
-
}
|
|
6508
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
6490
6509
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
6491
6510
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
6492
6511
|
}
|
|
@@ -6626,9 +6645,7 @@
|
|
|
6626
6645
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
6627
6646
|
}
|
|
6628
6647
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
6629
|
-
|
|
6630
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
6631
|
-
}
|
|
6648
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
6632
6649
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
6633
6650
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
6634
6651
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6706,9 +6723,7 @@
|
|
|
6706
6723
|
let extraFieldSize = 0;
|
|
6707
6724
|
let offset = 0;
|
|
6708
6725
|
extraField.forEach((data, type) => {
|
|
6709
|
-
|
|
6710
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6711
|
-
}
|
|
6726
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6712
6727
|
if (!(data instanceof Uint8Array)) {
|
|
6713
6728
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6714
6729
|
}
|
|
@@ -6783,6 +6798,10 @@
|
|
|
6783
6798
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6784
6799
|
}
|
|
6785
6800
|
}
|
|
6801
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6802
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6803
|
+
dataDescriptor = false;
|
|
6804
|
+
}
|
|
6786
6805
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6787
6806
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6788
6807
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6797,6 +6816,7 @@
|
|
|
6797
6816
|
maximumCompressedSize,
|
|
6798
6817
|
resolvedOptions: {
|
|
6799
6818
|
dataDescriptor,
|
|
6819
|
+
emptyEntry,
|
|
6800
6820
|
zip64,
|
|
6801
6821
|
zip64UncompressedSize,
|
|
6802
6822
|
zip64CompressedSize,
|
|
@@ -6816,6 +6836,7 @@
|
|
|
6816
6836
|
const {
|
|
6817
6837
|
keepOrder,
|
|
6818
6838
|
dataDescriptor,
|
|
6839
|
+
emptyEntry,
|
|
6819
6840
|
signal
|
|
6820
6841
|
} = options;
|
|
6821
6842
|
const {
|
|
@@ -6840,7 +6861,7 @@
|
|
|
6840
6861
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6841
6862
|
requestLockCurrentFileEntry();
|
|
6842
6863
|
}
|
|
6843
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6864
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6844
6865
|
bufferedWrite = true;
|
|
6845
6866
|
zipWriter.bufferedWrites++;
|
|
6846
6867
|
if (options.createTempStream) {
|
|
@@ -7262,8 +7283,8 @@
|
|
|
7262
7283
|
try {
|
|
7263
7284
|
const { uid, gid, unixExtraFieldType } = options;
|
|
7264
7285
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
7265
|
-
const uidBytes = packUnixId(uid);
|
|
7266
|
-
const gidBytes = packUnixId(gid);
|
|
7286
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
7287
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
7267
7288
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
7268
7289
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
7269
7290
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -7302,12 +7323,13 @@
|
|
|
7302
7323
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
7303
7324
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
7304
7325
|
}
|
|
7305
|
-
rawExtraFieldAES
|
|
7326
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
7306
7327
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
7307
7328
|
}
|
|
7308
7329
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
7309
7330
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
7310
|
-
|
|
7331
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
7332
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
7311
7333
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7312
7334
|
}
|
|
7313
7335
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -7393,18 +7415,14 @@
|
|
|
7393
7415
|
}
|
|
7394
7416
|
|
|
7395
7417
|
function packUnixId(id) {
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
let length = 4;
|
|
7403
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7404
|
-
length--;
|
|
7405
|
-
}
|
|
7406
|
-
return dataArray.subarray(0, length);
|
|
7418
|
+
const dataArray = new Uint8Array(4);
|
|
7419
|
+
const dataView = getDataView(dataArray);
|
|
7420
|
+
dataView.setUint32(0, id, true);
|
|
7421
|
+
let length = 4;
|
|
7422
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
7423
|
+
length--;
|
|
7407
7424
|
}
|
|
7425
|
+
return dataArray.subarray(0, length);
|
|
7408
7426
|
}
|
|
7409
7427
|
|
|
7410
7428
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7708,7 +7726,11 @@
|
|
|
7708
7726
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7709
7727
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7710
7728
|
signatureRecord.writeBytes(signatureData);
|
|
7711
|
-
|
|
7729
|
+
const { writer } = zipWriter;
|
|
7730
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7731
|
+
await writer.closeDisk();
|
|
7732
|
+
}
|
|
7733
|
+
await writeData(writer, signatureRecord.array);
|
|
7712
7734
|
return 6 + signatureDataLength;
|
|
7713
7735
|
}
|
|
7714
7736
|
return 0;
|
|
@@ -7819,7 +7841,22 @@
|
|
|
7819
7841
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7820
7842
|
}
|
|
7821
7843
|
|
|
7822
|
-
|
|
7844
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7845
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7846
|
+
let offsetExtraField = 0;
|
|
7847
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7848
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7849
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7850
|
+
return removeExtraFieldZip64(concat(
|
|
7851
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7852
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7853
|
+
}
|
|
7854
|
+
offsetExtraField += size;
|
|
7855
|
+
}
|
|
7856
|
+
return rawExtraField;
|
|
7857
|
+
}
|
|
7858
|
+
|
|
7859
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7823
7860
|
const { writer } = zipWriter;
|
|
7824
7861
|
const entryPositions = new Map();
|
|
7825
7862
|
if (writer.closeDisk) {
|
|
@@ -7840,9 +7877,10 @@
|
|
|
7840
7877
|
}
|
|
7841
7878
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7842
7879
|
} else {
|
|
7880
|
+
const baseOffset = zipWriter.offset;
|
|
7843
7881
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7844
7882
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7845
|
-
offset:
|
|
7883
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7846
7884
|
diskNumberStart: 0
|
|
7847
7885
|
}));
|
|
7848
7886
|
}
|
|
@@ -8695,6 +8733,7 @@
|
|
|
8695
8733
|
exports.ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH = ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH;
|
|
8696
8734
|
exports.ERR_UNSUPPORTED_ENCRYPTION_USDZ = ERR_UNSUPPORTED_ENCRYPTION_USDZ;
|
|
8697
8735
|
exports.ERR_UNSUPPORTED_FORMAT = ERR_UNSUPPORTED_FORMAT;
|
|
8736
|
+
exports.ERR_UNSUPPORTED_UINT64 = ERR_UNSUPPORTED_UINT64;
|
|
8698
8737
|
exports.ERR_WORKER_STARTUP_TIMEOUT = ERR_WORKER_STARTUP_TIMEOUT;
|
|
8699
8738
|
exports.ERR_WRITER_NOT_INITIALIZED = ERR_WRITER_NOT_INITIALIZED;
|
|
8700
8739
|
exports.ERR_ZIP_NOT_EMPTY = ERR_ZIP_NOT_EMPTY;
|