@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-fs-core.js
CHANGED
|
@@ -234,6 +234,18 @@
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
function checkInteger(value, maxValue, errorMessage) {
|
|
238
|
+
if (!Number.isInteger(value) || value < 0 || value > maxValue) {
|
|
239
|
+
throw new Error(errorMessage);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function checkIntegerOption(value, maxValue, errorMessage) {
|
|
244
|
+
if (value !== UNDEFINED_VALUE) {
|
|
245
|
+
checkInteger(value, maxValue, errorMessage);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
237
249
|
function toNumber(value) {
|
|
238
250
|
return typeof value == STRING_TYPE && value.trim() ? Number(value) : value;
|
|
239
251
|
}
|
|
@@ -4110,6 +4122,7 @@
|
|
|
4110
4122
|
const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced' or 'tolerant')";
|
|
4111
4123
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4112
4124
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4125
|
+
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4113
4126
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4114
4127
|
const CHARSET_UTF8 = "utf-8";
|
|
4115
4128
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4132,6 +4145,7 @@
|
|
|
4132
4145
|
bytes: 8
|
|
4133
4146
|
}
|
|
4134
4147
|
};
|
|
4148
|
+
const MAX_SAFE_UINT64 = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4135
4149
|
const MAX_END_OF_CENTRAL_DIR_PROBES = 64;
|
|
4136
4150
|
const MAX_DEFLATE_EXPANSION_RATIO = 1032;
|
|
4137
4151
|
const CENTRAL_DIRECTORY_UNREACHABLE = 0;
|
|
@@ -4227,7 +4241,7 @@
|
|
|
4227
4241
|
zip64EndOfDirectoryVersion2 = getBigUint64(endOfDirectoryView, 4) > ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12;
|
|
4228
4242
|
if (zip64EndOfDirectoryVersion2) {
|
|
4229
4243
|
const extensibleDataLength = Math.min(
|
|
4230
|
-
|
|
4244
|
+
getBigUint64(endOfDirectoryView, 4) - (ZIP64_END_OF_CENTRAL_DIR_LENGTH - 12),
|
|
4231
4245
|
reader.size - directoryDataOffset - ZIP64_END_OF_CENTRAL_DIR_LENGTH);
|
|
4232
4246
|
if (extensibleDataLength > 0) {
|
|
4233
4247
|
zip64EndOfDirectoryLength += extensibleDataLength;
|
|
@@ -4460,8 +4474,15 @@
|
|
|
4460
4474
|
yield entry;
|
|
4461
4475
|
}
|
|
4462
4476
|
let offsetAfterSignature = offset;
|
|
4463
|
-
|
|
4477
|
+
let digitalSignature = readDigitalSignature(directoryArray.subarray(offset)) ||
|
|
4464
4478
|
(decryptedDirectory ? readDigitalSignature(dataAfterEncryptedDirectory) : UNDEFINED_VALUE);
|
|
4479
|
+
if (!digitalSignature && !decryptedDirectory) {
|
|
4480
|
+
const signatureRecordOffset = directoryDataOffset + offset;
|
|
4481
|
+
const signatureRecordLength = Math.min(centralDirectoryEndOffset - signatureRecordOffset, 6 + MAX_16_BITS);
|
|
4482
|
+
if (signatureRecordLength >= 6) {
|
|
4483
|
+
digitalSignature = readDigitalSignature(await readUint8Array(reader, signatureRecordOffset, signatureRecordLength));
|
|
4484
|
+
}
|
|
4485
|
+
}
|
|
4465
4486
|
if (digitalSignature) {
|
|
4466
4487
|
zipReader.digitalSignature = digitalSignature;
|
|
4467
4488
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
@@ -4761,8 +4782,8 @@
|
|
|
4761
4782
|
const hashDataLength = getUint16$1(extensibleDataView, 26);
|
|
4762
4783
|
Object.assign(directoryEncryptionInfo, {
|
|
4763
4784
|
compressionMethod: getUint16$1(extensibleDataView, 0),
|
|
4764
|
-
compressedSize:
|
|
4765
|
-
uncompressedSize:
|
|
4785
|
+
compressedSize: getBigUint64(extensibleDataView, 2),
|
|
4786
|
+
uncompressedSize: getBigUint64(extensibleDataView, 10),
|
|
4766
4787
|
encryptionAlgorithm: getUint16$1(extensibleDataView, 18),
|
|
4767
4788
|
bitLength: getUint16$1(extensibleDataView, 20),
|
|
4768
4789
|
flags: getUint16$1(extensibleDataView, 22),
|
|
@@ -5397,7 +5418,11 @@
|
|
|
5397
5418
|
}
|
|
5398
5419
|
|
|
5399
5420
|
function getBigUint64(view, offset) {
|
|
5400
|
-
|
|
5421
|
+
const value = view.getBigUint64(offset, true);
|
|
5422
|
+
if (value > MAX_SAFE_UINT64) {
|
|
5423
|
+
throw new Error(ERR_UNSUPPORTED_UINT64);
|
|
5424
|
+
}
|
|
5425
|
+
return Number(value);
|
|
5401
5426
|
}
|
|
5402
5427
|
|
|
5403
5428
|
var zipReader = /*#__PURE__*/Object.freeze({
|
|
@@ -5426,6 +5451,7 @@
|
|
|
5426
5451
|
ERR_UNSAFE_FILENAME: ERR_UNSAFE_FILENAME,
|
|
5427
5452
|
ERR_UNSUPPORTED_COMPRESSION: ERR_UNSUPPORTED_COMPRESSION$1,
|
|
5428
5453
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
5454
|
+
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
5429
5455
|
ZipReader: ZipReader
|
|
5430
5456
|
});
|
|
5431
5457
|
|
|
@@ -5496,6 +5522,8 @@
|
|
|
5496
5522
|
|
|
5497
5523
|
const EXTRAFIELD_DATA_AES = new Uint8Array([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
|
|
5498
5524
|
const EXTRAFIELD_OFFSET_AES_VENDOR_VERSION = 4;
|
|
5525
|
+
const EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD = 9;
|
|
5526
|
+
const EXTRAFIELD_USDZ_MAX_LENGTH = 67;
|
|
5499
5527
|
const VENDOR_VERSION_AE_1 = 1;
|
|
5500
5528
|
const INFOZIP_EXTRA_FIELD_TYPE$1 = "infozip";
|
|
5501
5529
|
const UNIX_EXTRA_FIELD_TYPE = "unix";
|
|
@@ -5542,16 +5570,14 @@
|
|
|
5542
5570
|
await zipReader$1.close();
|
|
5543
5571
|
await initStream(this.writer);
|
|
5544
5572
|
const { directoryOffset } = zipReader$1;
|
|
5545
|
-
let splitZipSignatureLength = 0;
|
|
5546
5573
|
if (this.addSplitZipSignature) {
|
|
5547
5574
|
delete this.addSplitZipSignature;
|
|
5548
5575
|
if (!await startsWithSplitZipSignature(reader)) {
|
|
5549
5576
|
await writeData(this.writer, getSplitZipSignatureArray());
|
|
5550
|
-
|
|
5551
|
-
this.offset += splitZipSignatureLength;
|
|
5577
|
+
this.offset += SPLIT_ZIP_FILE_SIGNATURE_LENGTH;
|
|
5552
5578
|
}
|
|
5553
5579
|
}
|
|
5554
|
-
const entryPositions = await copyZipData(this, reader, entries, directoryOffset
|
|
5580
|
+
const entryPositions = await copyZipData(this, reader, entries, directoryOffset);
|
|
5555
5581
|
this.filenames = new Set(entries.map(entry => entry.filename));
|
|
5556
5582
|
this.fileEntries = new Map(entries.map(entry => {
|
|
5557
5583
|
const {
|
|
@@ -5564,7 +5590,7 @@
|
|
|
5564
5590
|
encrypted,
|
|
5565
5591
|
uncompressedSize,
|
|
5566
5592
|
compressedSize,
|
|
5567
|
-
|
|
5593
|
+
extraFieldZip64
|
|
5568
5594
|
} = entry;
|
|
5569
5595
|
let {
|
|
5570
5596
|
compressionMethod,
|
|
@@ -5581,13 +5607,13 @@
|
|
|
5581
5607
|
rawExtraFieldExtendedTimestamp = rawExtraFieldExtendedTimestamp || EMPTY_UINT8_ARRAY;
|
|
5582
5608
|
rawExtraFieldNTFS = rawExtraFieldNTFS || EMPTY_UINT8_ARRAY;
|
|
5583
5609
|
rawExtraFieldUnix = rawExtraFieldUnix || EMPTY_UINT8_ARRAY;
|
|
5584
|
-
rawExtraField = rawExtraField || EMPTY_UINT8_ARRAY;
|
|
5610
|
+
rawExtraField = removeExtraFieldZip64(rawExtraField || EMPTY_UINT8_ARRAY);
|
|
5585
5611
|
if (entry.extraFieldAES) {
|
|
5586
5612
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
5587
5613
|
}
|
|
5588
5614
|
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
5589
|
-
const zip64UncompressedSize =
|
|
5590
|
-
const zip64CompressedSize =
|
|
5615
|
+
const zip64UncompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.uncompressedSize !== UNDEFINED_VALUE;
|
|
5616
|
+
const zip64CompressedSize = Boolean(extraFieldZip64) && extraFieldZip64.compressedSize !== UNDEFINED_VALUE;
|
|
5591
5617
|
const bitFlagValue = (getBitFlag(level, languageEncodingFlag, dataDescriptor, encrypted, compressionMethod) & ~BITFLAG_LEVEL) | (level << 1);
|
|
5592
5618
|
const {
|
|
5593
5619
|
headerArray,
|
|
@@ -5731,7 +5757,8 @@
|
|
|
5731
5757
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
5732
5758
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
5733
5759
|
offset: zipWriter.offset - diskOffset,
|
|
5734
|
-
diskNumberStart: diskNumber
|
|
5760
|
+
diskNumberStart: diskNumber,
|
|
5761
|
+
[OPTION_USDZ]: zipWriter.options[OPTION_USDZ]
|
|
5735
5762
|
});
|
|
5736
5763
|
const headerInfo = getHeaderInfo(options);
|
|
5737
5764
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
@@ -5763,15 +5790,9 @@
|
|
|
5763
5790
|
let setuid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETUID);
|
|
5764
5791
|
let setgid = getOptionValue(zipWriter, options, PROPERTY_NAME_SETGID);
|
|
5765
5792
|
let sticky = getOptionValue(zipWriter, options, PROPERTY_NAME_STICKY);
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
if (gid !== UNDEFINED_VALUE && (!Number.isInteger(gid) || gid < 0 || gid > MAX_32_BITS)) {
|
|
5770
|
-
throw new Error(ERR_INVALID_GID);
|
|
5771
|
-
}
|
|
5772
|
-
if (unixMode !== UNDEFINED_VALUE && (!Number.isInteger(unixMode) || unixMode < 0 || unixMode > MAX_16_BITS)) {
|
|
5773
|
-
throw new Error(ERR_INVALID_UNIX_MODE);
|
|
5774
|
-
}
|
|
5793
|
+
checkIntegerOption(uid, MAX_32_BITS, ERR_INVALID_UID);
|
|
5794
|
+
checkIntegerOption(gid, MAX_32_BITS, ERR_INVALID_GID);
|
|
5795
|
+
checkIntegerOption(unixMode, MAX_16_BITS, ERR_INVALID_UNIX_MODE);
|
|
5775
5796
|
if (unixExtraFieldType !== UNDEFINED_VALUE && unixExtraFieldType !== INFOZIP_EXTRA_FIELD_TYPE$1 && unixExtraFieldType !== UNIX_EXTRA_FIELD_TYPE) {
|
|
5776
5797
|
throw new Error(ERR_INVALID_UNIX_EXTRA_FIELD_TYPE);
|
|
5777
5798
|
}
|
|
@@ -5793,9 +5814,7 @@
|
|
|
5793
5814
|
msDosCompatible = true;
|
|
5794
5815
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
5795
5816
|
}
|
|
5796
|
-
|
|
5797
|
-
throw new Error(ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
5798
|
-
}
|
|
5817
|
+
checkIntegerOption(msdosAttributesRaw, MAX_8_BITS, ERR_INVALID_MSDOS_ATTRIBUTES);
|
|
5799
5818
|
if (msdosAttributes && (typeof msdosAttributes !== OBJECT_TYPE || Array.isArray(msdosAttributes))) {
|
|
5800
5819
|
throw new Error(ERR_INVALID_MSDOS_DATA);
|
|
5801
5820
|
}
|
|
@@ -5935,9 +5954,7 @@
|
|
|
5935
5954
|
throw new Error(ERR_UNSUPPORTED_COMPRESSION);
|
|
5936
5955
|
}
|
|
5937
5956
|
let level = getNumberOptionValue(zipWriter, options, OPTION_LEVEL);
|
|
5938
|
-
|
|
5939
|
-
throw new Error(ERR_INVALID_LEVEL);
|
|
5940
|
-
}
|
|
5957
|
+
checkIntegerOption(level, MAX_LEVEL, ERR_INVALID_LEVEL);
|
|
5941
5958
|
if (zipWriter.options[OPTION_USDZ]) {
|
|
5942
5959
|
if (password !== UNDEFINED_VALUE || rawPassword !== UNDEFINED_VALUE) {
|
|
5943
5960
|
throw new Error(ERR_UNSUPPORTED_ENCRYPTION_USDZ);
|
|
@@ -6015,9 +6032,7 @@
|
|
|
6015
6032
|
let extraFieldSize = 0;
|
|
6016
6033
|
let offset = 0;
|
|
6017
6034
|
extraField.forEach((data, type) => {
|
|
6018
|
-
|
|
6019
|
-
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6020
|
-
}
|
|
6035
|
+
checkInteger(type, MAX_16_BITS, ERR_INVALID_EXTRAFIELD_TYPE);
|
|
6021
6036
|
if (!(data instanceof Uint8Array)) {
|
|
6022
6037
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA_TYPE);
|
|
6023
6038
|
}
|
|
@@ -6092,6 +6107,10 @@
|
|
|
6092
6107
|
maximumCompressedSize = contentSize === UNDEFINED_VALUE ? getMaximumCompressedSize(uncompressedSize) + encryptionOverhead : contentSize;
|
|
6093
6108
|
}
|
|
6094
6109
|
}
|
|
6110
|
+
const emptyEntry = !encryptedEntry && (!hasContent || (contentSize === 0 && !passThrough)) && !isCompressed(compressionMethod, level);
|
|
6111
|
+
if (emptyEntry && !zipCrypto && getOptionValue(zipWriter, options, OPTION_DATA_DESCRIPTOR) === UNDEFINED_VALUE) {
|
|
6112
|
+
dataDescriptor = false;
|
|
6113
|
+
}
|
|
6095
6114
|
const zip64UncompressedSize = zip64Enabled || uncompressedSize >= MAX_32_BITS;
|
|
6096
6115
|
const zip64CompressedSize = zip64Enabled || maximumCompressedSize >= MAX_32_BITS;
|
|
6097
6116
|
if (zip64UncompressedSize || zip64CompressedSize) {
|
|
@@ -6106,6 +6125,7 @@
|
|
|
6106
6125
|
maximumCompressedSize,
|
|
6107
6126
|
resolvedOptions: {
|
|
6108
6127
|
dataDescriptor,
|
|
6128
|
+
emptyEntry,
|
|
6109
6129
|
zip64,
|
|
6110
6130
|
zip64UncompressedSize,
|
|
6111
6131
|
zip64CompressedSize,
|
|
@@ -6132,7 +6152,9 @@
|
|
|
6132
6152
|
const usdz = writerOptions[OPTION_USDZ];
|
|
6133
6153
|
const files = new Map();
|
|
6134
6154
|
let layoutDependsOnWriteOrder = Boolean(usdz);
|
|
6135
|
-
|
|
6155
|
+
const initialOffset = writerOptions[OPTION_OFFSET] === UNDEFINED_VALUE ? 0 : writerOptions[OPTION_OFFSET];
|
|
6156
|
+
let offset = initialOffset;
|
|
6157
|
+
let minimumEntrySize = INFINITY_VALUE;
|
|
6136
6158
|
for (const entry of entries) {
|
|
6137
6159
|
let { name } = entry;
|
|
6138
6160
|
const { size } = entry;
|
|
@@ -6156,7 +6178,7 @@
|
|
|
6156
6178
|
if (hasContent && !metadata.passThrough && isCompressed(sizes.compressionMethod, sizes.level)) {
|
|
6157
6179
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
6158
6180
|
}
|
|
6159
|
-
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes);
|
|
6181
|
+
const entryOptions = Object.assign({}, options, attributesInfo.resolvedOptions, metadata, sizes, { [OPTION_USDZ]: usdz });
|
|
6160
6182
|
const headerInfo = getHeaderInfo(entryOptions);
|
|
6161
6183
|
const dataDescriptorInfo = getDataDescriptorInfo(entryOptions);
|
|
6162
6184
|
const entryInfo = {
|
|
@@ -6167,15 +6189,17 @@
|
|
|
6167
6189
|
appendExtraFieldUSDZ(entryInfo, offset);
|
|
6168
6190
|
}
|
|
6169
6191
|
const compressedSize = hasContent ? maximumCompressedSize : 0;
|
|
6170
|
-
if (offset >= MAX_32_BITS) {
|
|
6171
|
-
layoutDependsOnWriteOrder = true;
|
|
6172
|
-
}
|
|
6173
6192
|
files.set(name, Object.assign({}, entryOptions, headerInfo, {
|
|
6174
6193
|
offset,
|
|
6175
6194
|
diskNumberStart: 0,
|
|
6176
6195
|
compressedSize
|
|
6177
6196
|
}));
|
|
6178
|
-
|
|
6197
|
+
const entrySize = entryInfo.metadataSize + compressedSize;
|
|
6198
|
+
minimumEntrySize = Math.min(minimumEntrySize, entrySize);
|
|
6199
|
+
offset += entrySize;
|
|
6200
|
+
}
|
|
6201
|
+
if (files.size && offset - minimumEntrySize >= MAX_32_BITS) {
|
|
6202
|
+
layoutDependsOnWriteOrder = true;
|
|
6179
6203
|
}
|
|
6180
6204
|
if (layoutDependsOnWriteOrder && !writeOrderGuaranteed) {
|
|
6181
6205
|
throw new Error(ERR_UNDETERMINED_SIZE);
|
|
@@ -6189,7 +6213,7 @@
|
|
|
6189
6213
|
zip64 = true;
|
|
6190
6214
|
}
|
|
6191
6215
|
}
|
|
6192
|
-
return offset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6216
|
+
return offset - initialOffset + directoryDataLength + commentLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH);
|
|
6193
6217
|
}
|
|
6194
6218
|
|
|
6195
6219
|
async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
@@ -6200,6 +6224,7 @@
|
|
|
6200
6224
|
const {
|
|
6201
6225
|
keepOrder,
|
|
6202
6226
|
dataDescriptor,
|
|
6227
|
+
emptyEntry,
|
|
6203
6228
|
signal
|
|
6204
6229
|
} = options;
|
|
6205
6230
|
const {
|
|
@@ -6224,7 +6249,7 @@
|
|
|
6224
6249
|
lockPreviousFileEntry = previousFileEntry && previousFileEntry.lockFileEntry;
|
|
6225
6250
|
requestLockCurrentFileEntry();
|
|
6226
6251
|
}
|
|
6227
|
-
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || !dataDescriptor) {
|
|
6252
|
+
if (options.bufferedWrite || !keepOrder || zipWriter.writerLocked || zipWriter.bufferedWrites || (!dataDescriptor && !emptyEntry)) {
|
|
6228
6253
|
bufferedWrite = true;
|
|
6229
6254
|
zipWriter.bufferedWrites++;
|
|
6230
6255
|
if (options.createTempStream) {
|
|
@@ -6646,8 +6671,8 @@
|
|
|
6646
6671
|
try {
|
|
6647
6672
|
const { uid, gid, unixExtraFieldType } = options;
|
|
6648
6673
|
if (unixExtraFieldType == INFOZIP_EXTRA_FIELD_TYPE$1 && (uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE)) {
|
|
6649
|
-
const uidBytes = packUnixId(uid);
|
|
6650
|
-
const gidBytes = packUnixId(gid);
|
|
6674
|
+
const uidBytes = packUnixId(uid === UNDEFINED_VALUE ? 0 : uid);
|
|
6675
|
+
const gidBytes = packUnixId(gid === UNDEFINED_VALUE ? 0 : gid);
|
|
6651
6676
|
const payloadLength = 3 + uidBytes.length + gidBytes.length;
|
|
6652
6677
|
const extraFieldUnix = createRecordWriter(4 + payloadLength);
|
|
6653
6678
|
extraFieldUnix.writeUint16(EXTRAFIELD_TYPE_INFOZIP);
|
|
@@ -6686,12 +6711,13 @@
|
|
|
6686
6711
|
if (passThrough && crc32 !== UNDEFINED_VALUE) {
|
|
6687
6712
|
rawExtraFieldAES[EXTRAFIELD_OFFSET_AES_VENDOR_VERSION] = VENDOR_VERSION_AE_1;
|
|
6688
6713
|
}
|
|
6689
|
-
rawExtraFieldAES
|
|
6714
|
+
setUint16(getDataView(rawExtraFieldAES), EXTRAFIELD_OFFSET_AES_COMPRESSION_METHOD, compressionMethod);
|
|
6690
6715
|
compressionMethod = COMPRESSION_METHOD_AES;
|
|
6691
6716
|
}
|
|
6692
6717
|
const localExtraFieldZip64Length = writeLocalExtraFieldZip64 ? getLength(rawLocalExtraFieldZip64) : 0;
|
|
6693
6718
|
const extraFieldLength = localExtraFieldZip64Length + getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawLocalExtraField);
|
|
6694
|
-
|
|
6719
|
+
const maximumUsdzExtraFieldLength = options[OPTION_USDZ] ? EXTRAFIELD_USDZ_MAX_LENGTH : 0;
|
|
6720
|
+
if (extraFieldLength + maximumUsdzExtraFieldLength > MAX_16_BITS) {
|
|
6695
6721
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
6696
6722
|
}
|
|
6697
6723
|
const dosLastModDate = new Date(Math.ceil(Math.floor(lastModDate.getTime() / 1000) / 2) * 2000);
|
|
@@ -6777,18 +6803,14 @@
|
|
|
6777
6803
|
}
|
|
6778
6804
|
|
|
6779
6805
|
function packUnixId(id) {
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
let length = 4;
|
|
6787
|
-
while (length > 1 && dataArray[length - 1] === 0) {
|
|
6788
|
-
length--;
|
|
6789
|
-
}
|
|
6790
|
-
return dataArray.subarray(0, length);
|
|
6806
|
+
const dataArray = new Uint8Array(4);
|
|
6807
|
+
const dataView = getDataView(dataArray);
|
|
6808
|
+
dataView.setUint32(0, id, true);
|
|
6809
|
+
let length = 4;
|
|
6810
|
+
while (length > 1 && dataArray[length - 1] === 0) {
|
|
6811
|
+
length--;
|
|
6791
6812
|
}
|
|
6813
|
+
return dataArray.subarray(0, length);
|
|
6792
6814
|
}
|
|
6793
6815
|
|
|
6794
6816
|
function normalizeMsdosAttributes(msdosAttributesRaw, msdosAttributes) {
|
|
@@ -7092,7 +7114,11 @@
|
|
|
7092
7114
|
signatureRecord.writeUint32(DIGITAL_SIGNATURE_RECORD_SIGNATURE);
|
|
7093
7115
|
signatureRecord.writeUint16(signatureDataLength);
|
|
7094
7116
|
signatureRecord.writeBytes(signatureData);
|
|
7095
|
-
|
|
7117
|
+
const { writer } = zipWriter;
|
|
7118
|
+
if (exceedsAvailableSize(writer, getLength(signatureRecord.array))) {
|
|
7119
|
+
await writer.closeDisk();
|
|
7120
|
+
}
|
|
7121
|
+
await writeData(writer, signatureRecord.array);
|
|
7096
7122
|
return 6 + signatureDataLength;
|
|
7097
7123
|
}
|
|
7098
7124
|
return 0;
|
|
@@ -7203,7 +7229,22 @@
|
|
|
7203
7229
|
return getUint32(getDataView(signatureArray), 0) == SPLIT_ZIP_FILE_SIGNATURE;
|
|
7204
7230
|
}
|
|
7205
7231
|
|
|
7206
|
-
|
|
7232
|
+
function removeExtraFieldZip64(rawExtraField) {
|
|
7233
|
+
const rawExtraFieldView = getDataView(rawExtraField);
|
|
7234
|
+
let offsetExtraField = 0;
|
|
7235
|
+
while (offsetExtraField + 4 <= getLength(rawExtraField)) {
|
|
7236
|
+
const size = 4 + getUint16(rawExtraFieldView, offsetExtraField + 2);
|
|
7237
|
+
if (getUint16(rawExtraFieldView, offsetExtraField) == EXTRAFIELD_TYPE_ZIP64) {
|
|
7238
|
+
return removeExtraFieldZip64(concat(
|
|
7239
|
+
rawExtraField.subarray(0, offsetExtraField),
|
|
7240
|
+
rawExtraField.subarray(Math.min(offsetExtraField + size, getLength(rawExtraField)))));
|
|
7241
|
+
}
|
|
7242
|
+
offsetExtraField += size;
|
|
7243
|
+
}
|
|
7244
|
+
return rawExtraField;
|
|
7245
|
+
}
|
|
7246
|
+
|
|
7247
|
+
async function copyZipData(zipWriter, reader, entries, directoryOffset) {
|
|
7207
7248
|
const { writer } = zipWriter;
|
|
7208
7249
|
const entryPositions = new Map();
|
|
7209
7250
|
if (writer.closeDisk) {
|
|
@@ -7224,9 +7265,10 @@
|
|
|
7224
7265
|
}
|
|
7225
7266
|
await copyData(zipWriter, reader, copiedLength, directoryOffset - copiedLength);
|
|
7226
7267
|
} else {
|
|
7268
|
+
const baseOffset = zipWriter.offset;
|
|
7227
7269
|
await copyData(zipWriter, reader, 0, directoryOffset);
|
|
7228
7270
|
entries.forEach(entry => entryPositions.set(entry, {
|
|
7229
|
-
offset:
|
|
7271
|
+
offset: baseOffset + getSourceOffset(reader, entry),
|
|
7230
7272
|
diskNumberStart: 0
|
|
7231
7273
|
}));
|
|
7232
7274
|
}
|
|
@@ -8251,7 +8293,7 @@
|
|
|
8251
8293
|
} else if (writer.constructor == BlobWriter) {
|
|
8252
8294
|
return data.type == contentType;
|
|
8253
8295
|
} else if (writer.constructor == Data64URIWriter) {
|
|
8254
|
-
return data.startsWith(
|
|
8296
|
+
return data.startsWith("data:" + (contentType || "") + ";base64,");
|
|
8255
8297
|
} else {
|
|
8256
8298
|
return true;
|
|
8257
8299
|
}
|