@zip.js/zip.js 2.8.58 → 2.8.59
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 +157 -39
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +171 -38
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +157 -40
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +156 -39
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +157 -40
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +171 -39
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +171 -39
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +171 -38
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +171 -38
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +171 -38
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +171 -39
- package/index-native.min.js +1 -1
- package/index.cjs +171 -39
- package/index.d.cts +184 -1
- package/index.d.ts +184 -1
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -0
- package/lib/core/options.js +2 -0
- package/lib/core/zip-reader.js +143 -33
- package/lib/core/zip-writer.js +13 -6
- package/lib/zip-core-reader.js +16 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -77,6 +77,7 @@ const BITFLAG_LEVEL_MAX_MASK = 0b010;
|
|
|
77
77
|
const BITFLAG_LEVEL_FAST_MASK = 0b100;
|
|
78
78
|
const BITFLAG_LEVEL_SUPER_FAST_MASK = 0b110;
|
|
79
79
|
const BITFLAG_DATA_DESCRIPTOR = 0b1000;
|
|
80
|
+
const BITFLAG_COMPRESSED_PATCHED_DATA = 0b100000;
|
|
80
81
|
const BITFLAG_STRONG_ENCRYPTION = 0b1000000;
|
|
81
82
|
const BITFLAG_LANG_ENCODING_FLAG = 0b100000000000;
|
|
82
83
|
const BITFLAG_MASKED_LOCAL_HEADERS = 0b10000000000000;
|
|
@@ -194,6 +195,7 @@ const OPTION_OFFSET = "offset";
|
|
|
194
195
|
const OPTION_USDZ = "usdz";
|
|
195
196
|
const OPTION_UNIX_EXTRA_FIELD_TYPE = "unixExtraFieldType";
|
|
196
197
|
const OPTION_LOCAL_EXTRA_FIELD = "localExtraField";
|
|
198
|
+
const OPTION_CENTRAL_EXTRA_FIELD = "centralExtraField";
|
|
197
199
|
const OPTION_STRICTNESS = "strictness";
|
|
198
200
|
const OPTION_FILENAME_VALIDATION = "filenameValidation";
|
|
199
201
|
const OPTION_NORMALIZE_FILENAME = "normalizeFilename";
|
|
@@ -4729,6 +4731,21 @@ const ERR_INVALID_STRICTNESS = "Invalid strictness (must be 'strict', 'balanced'
|
|
|
4729
4731
|
const ERR_INVALID_FILENAME_VALIDATION = "Invalid filenameValidation (must be 'strict', 'balanced' or 'tolerant')";
|
|
4730
4732
|
const ERR_INVALID_MAX_APPENDED_DATA_SIZE = "Invalid maxAppendedDataSize (must be a number greater than or equal to 0)";
|
|
4731
4733
|
const ERR_UNSUPPORTED_UINT64 = "64-bit value exceeds Number.MAX_SAFE_INTEGER";
|
|
4734
|
+
const WARNING_UNSORTED_CENTRAL_DIRECTORY = "unsorted central directory";
|
|
4735
|
+
const WARNING_UNKNOWN_VERSION = "unknown version needed to extract";
|
|
4736
|
+
const WARNING_COMPRESSED_PATCHED_DATA = "compressed patched data";
|
|
4737
|
+
const WARNING_MALFORMED_EXTRA_FIELD = "malformed extra field";
|
|
4738
|
+
const WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA = "unknown zip64 extensible data";
|
|
4739
|
+
const WARNING_WRAPPED_ENTRIES_COUNT = "wrapped entries count";
|
|
4740
|
+
const WARNING_APPENDED_DATA = "appended data";
|
|
4741
|
+
const WARNING_PREPENDED_DATA = "prepended data";
|
|
4742
|
+
const WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = "trailing central directory data";
|
|
4743
|
+
const WARNING_DUPLICATE_FILENAME = "duplicate filename";
|
|
4744
|
+
const WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = "mismatched zip64 end of central directory record";
|
|
4745
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = "mismatched local file header (general purpose bit flag)";
|
|
4746
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = "mismatched local file header (compression method)";
|
|
4747
|
+
const WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = "mismatched local file header (crc32 or sizes)";
|
|
4748
|
+
const MAX_KNOWN_VERSION = 63;
|
|
4732
4749
|
const DRIVE_LETTER_REGEXP = /^[a-zA-Z]:/;
|
|
4733
4750
|
const CHARSET_UTF8 = "utf-8";
|
|
4734
4751
|
const PROPERTY_NAME_UTF8_SUFFIX = "UTF8";
|
|
@@ -4779,6 +4796,7 @@ class ZipReader {
|
|
|
4779
4796
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4780
4797
|
throw new Error(ERR_BAD_FORMAT);
|
|
4781
4798
|
}
|
|
4799
|
+
const warnings = zipReader.warnings = [];
|
|
4782
4800
|
const strictness = getStrictness(options, zipReader.options);
|
|
4783
4801
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4784
4802
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
@@ -4802,8 +4820,12 @@ class ZipReader {
|
|
|
4802
4820
|
const commentOffset = endOfDirectoryInfo.offset;
|
|
4803
4821
|
const commentLength = getUint16$1(endOfDirectoryView, 20);
|
|
4804
4822
|
const appendedDataOffset = commentOffset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
4805
|
-
|
|
4806
|
-
|
|
4823
|
+
const appendedDataLength = reader.size - appendedDataOffset;
|
|
4824
|
+
if (appendedDataLength > maxAppendedDataSize) {
|
|
4825
|
+
throwAmbiguousArchive(WARNING_APPENDED_DATA);
|
|
4826
|
+
}
|
|
4827
|
+
if (appendedDataLength > 0) {
|
|
4828
|
+
addWarning(warnings, WARNING_APPENDED_DATA);
|
|
4807
4829
|
}
|
|
4808
4830
|
let lastDiskNumber = getUint16$1(endOfDirectoryView, 4);
|
|
4809
4831
|
const expectedLastDiskNumber = reader.lastDiskNumber || 0;
|
|
@@ -4857,23 +4879,23 @@ class ZipReader {
|
|
|
4857
4879
|
}
|
|
4858
4880
|
if (lastDiskNumber == MAX_16_BITS) {
|
|
4859
4881
|
lastDiskNumber = getUint32$1(endOfDirectoryView, 16);
|
|
4860
|
-
} else if (
|
|
4861
|
-
|
|
4882
|
+
} else if (lastDiskNumber != getUint32$1(endOfDirectoryView, 16)) {
|
|
4883
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4862
4884
|
}
|
|
4863
4885
|
if (diskNumber == MAX_16_BITS) {
|
|
4864
4886
|
diskNumber = getUint32$1(endOfDirectoryView, 20);
|
|
4865
|
-
} else if (
|
|
4866
|
-
|
|
4887
|
+
} else if (diskNumber != getUint32$1(endOfDirectoryView, 20)) {
|
|
4888
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4867
4889
|
}
|
|
4868
4890
|
if (filesLength == MAX_16_BITS) {
|
|
4869
4891
|
filesLength = getBigUint64(endOfDirectoryView, 32);
|
|
4870
|
-
} else if (
|
|
4871
|
-
|
|
4892
|
+
} else if (filesLength != getBigUint64(endOfDirectoryView, 32)) {
|
|
4893
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4872
4894
|
}
|
|
4873
4895
|
if (directoryDataLength == MAX_32_BITS) {
|
|
4874
4896
|
directoryDataLength = getBigUint64(endOfDirectoryView, 40);
|
|
4875
|
-
} else if (
|
|
4876
|
-
|
|
4897
|
+
} else if (directoryDataLength != getBigUint64(endOfDirectoryView, 40)) {
|
|
4898
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY);
|
|
4877
4899
|
}
|
|
4878
4900
|
directoryDataOffset = getDiskOffset$1(reader, diskNumber) + getBigUint64(endOfDirectoryView, 48) + prependedDataLength;
|
|
4879
4901
|
}
|
|
@@ -4942,14 +4964,22 @@ class ZipReader {
|
|
|
4942
4964
|
declaredDirectoryDataLength = directoryArray.length;
|
|
4943
4965
|
decryptedDirectory = true;
|
|
4944
4966
|
}
|
|
4967
|
+
if (directoryEncryptionInfo && !decryptedDirectory &&
|
|
4968
|
+
(directoryArray.length < 4 || getUint32$1(directoryView, 0) == CENTRAL_FILE_HEADER_SIGNATURE)) {
|
|
4969
|
+
addWarning(warnings, WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA);
|
|
4970
|
+
}
|
|
4945
4971
|
startOffset = directoryDataOffset;
|
|
4946
4972
|
const filenameEncoding = getOptionValue$1(zipReader, options, OPTION_FILENAME_ENCODING);
|
|
4947
4973
|
const commentEncoding = getOptionValue$1(zipReader, options, OPTION_COMMENT_ENCODING);
|
|
4948
|
-
const filenames =
|
|
4974
|
+
const filenames = new Set();
|
|
4949
4975
|
let duplicateFilename;
|
|
4976
|
+
let previousEntryPosition = -1;
|
|
4950
4977
|
const recoverWrappedFilesLength = !checkAmbiguity && !zip64EndOfDirectory;
|
|
4951
4978
|
if (!filesLength && recoverWrappedFilesLength) {
|
|
4952
4979
|
filesLength = getWrappedFilesLength(directoryView, directoryArray, offset);
|
|
4980
|
+
if (filesLength) {
|
|
4981
|
+
addWarning(warnings, WARNING_WRAPPED_ENTRIES_COUNT);
|
|
4982
|
+
}
|
|
4953
4983
|
}
|
|
4954
4984
|
for (let indexFile = 0; indexFile < filesLength; indexFile++) {
|
|
4955
4985
|
const fileEntry = new ZipEntry$1(reader, zipReader.options);
|
|
@@ -5028,15 +5058,26 @@ class ZipReader {
|
|
|
5028
5058
|
filename,
|
|
5029
5059
|
comment
|
|
5030
5060
|
});
|
|
5031
|
-
readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6)
|
|
5061
|
+
if (readCommonFooter(fileEntry, fileEntry, directoryView, offset + 6)) {
|
|
5062
|
+
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD, filename);
|
|
5063
|
+
}
|
|
5032
5064
|
fileEntry.offset += prependedDataLength;
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5065
|
+
const entryPosition = getDiskOffset$1(reader, fileEntry.diskNumberStart) + fileEntry.offset;
|
|
5066
|
+
startOffset = Math.min(entryPosition, startOffset);
|
|
5067
|
+
if (entryPosition < previousEntryPosition) {
|
|
5068
|
+
addWarning(warnings, WARNING_UNSORTED_CENTRAL_DIRECTORY, filename);
|
|
5069
|
+
}
|
|
5070
|
+
previousEntryPosition = entryPosition;
|
|
5071
|
+
if ((fileEntry.version & MAX_8_BITS) > MAX_KNOWN_VERSION) {
|
|
5072
|
+
addWarning(warnings, WARNING_UNKNOWN_VERSION, filename);
|
|
5073
|
+
}
|
|
5074
|
+
if ((fileEntry.rawBitFlag & BITFLAG_COMPRESSED_PATCHED_DATA) == BITFLAG_COMPRESSED_PATCHED_DATA) {
|
|
5075
|
+
addWarning(warnings, WARNING_COMPRESSED_PATCHED_DATA, filename);
|
|
5076
|
+
}
|
|
5077
|
+
if (filenames.has(fileEntry.filename)) {
|
|
5078
|
+
duplicateFilename = true;
|
|
5039
5079
|
}
|
|
5080
|
+
filenames.add(fileEntry.filename);
|
|
5040
5081
|
const unixExternalUpper = (fileEntry.externalFileAttributes >> 16) & MAX_16_BITS;
|
|
5041
5082
|
if (fileEntry.unixMode === UNDEFINED_VALUE && (unixExternalUpper & (FILE_ATTR_UNIX_DEFAULT_MASK | FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_TYPE_DIR)) != 0) {
|
|
5042
5083
|
fileEntry.unixMode = unixExternalUpper;
|
|
@@ -5074,7 +5115,11 @@ class ZipReader {
|
|
|
5074
5115
|
};
|
|
5075
5116
|
offset = endOffset;
|
|
5076
5117
|
if (indexFile == filesLength - 1 && recoverWrappedFilesLength) {
|
|
5077
|
-
|
|
5118
|
+
const wrappedFilesLength = getWrappedFilesLength(directoryView, directoryArray, offset);
|
|
5119
|
+
if (wrappedFilesLength) {
|
|
5120
|
+
filesLength += wrappedFilesLength;
|
|
5121
|
+
addWarning(warnings, WARNING_WRAPPED_ENTRIES_COUNT);
|
|
5122
|
+
}
|
|
5078
5123
|
}
|
|
5079
5124
|
const { onprogress } = options;
|
|
5080
5125
|
if (onprogress) {
|
|
@@ -5100,18 +5145,22 @@ class ZipReader {
|
|
|
5100
5145
|
zipReader.digitalSignature = digitalSignature;
|
|
5101
5146
|
offsetAfterSignature = offset + 6 + digitalSignature.length;
|
|
5102
5147
|
}
|
|
5103
|
-
if (
|
|
5104
|
-
|
|
5148
|
+
if ((offset != declaredDirectoryDataLength && offsetAfterSignature != declaredDirectoryDataLength) ||
|
|
5149
|
+
(!decryptedDirectory && offset != directoryDataLength && offsetAfterSignature != directoryDataLength)) {
|
|
5150
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_TRAILING_CENTRAL_DIRECTORY_DATA);
|
|
5105
5151
|
}
|
|
5106
5152
|
if (duplicateFilename) {
|
|
5107
|
-
|
|
5153
|
+
reportAmbiguity(checkAmbiguity, warnings, WARNING_DUPLICATE_FILENAME);
|
|
5108
5154
|
}
|
|
5109
5155
|
const extractPrependedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_PREPENDED_DATA);
|
|
5110
5156
|
const extractAppendedData = getOptionValue$1(zipReader, options, OPTION_EXTRACT_APPENDED_DATA);
|
|
5111
5157
|
const splitZipSignatureLength = (checkAmbiguity || extractPrependedData) && filesLength &&
|
|
5112
5158
|
startOffset == SPLIT_ZIP_FILE_SIGNATURE_LENGTH && await startsWithSplitZipMarker(reader) ? SPLIT_ZIP_FILE_SIGNATURE_LENGTH : 0;
|
|
5113
5159
|
if (checkAmbiguity && (prependedDataLength || (filesLength && startOffset > splitZipSignatureLength))) {
|
|
5114
|
-
throwAmbiguousArchive(
|
|
5160
|
+
throwAmbiguousArchive(WARNING_PREPENDED_DATA);
|
|
5161
|
+
}
|
|
5162
|
+
if (prependedDataLength || (filesLength && startOffset > SPLIT_ZIP_FILE_SIGNATURE_LENGTH)) {
|
|
5163
|
+
addWarning(warnings, WARNING_PREPENDED_DATA);
|
|
5115
5164
|
}
|
|
5116
5165
|
if (extractPrependedData) {
|
|
5117
5166
|
zipReader.prependedData = startOffset > splitZipSignatureLength ?
|
|
@@ -5181,6 +5230,28 @@ class ZipReaderStream {
|
|
|
5181
5230
|
}
|
|
5182
5231
|
}
|
|
5183
5232
|
|
|
5233
|
+
async function isZipFile(reader, options = {}) {
|
|
5234
|
+
reader = new GenericReader(reader);
|
|
5235
|
+
await initStream(reader);
|
|
5236
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
5237
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
5238
|
+
await initStream(reader);
|
|
5239
|
+
}
|
|
5240
|
+
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
5241
|
+
return false;
|
|
5242
|
+
}
|
|
5243
|
+
const strictness = getStrictness(options, {});
|
|
5244
|
+
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
5245
|
+
const maxAppendedDataSize = getMaxAppendedDataSize(options[OPTION_MAX_APPENDED_DATA_SIZE], strictness);
|
|
5246
|
+
const { endOfDirectoryInfo, endOfDirectoryReachingEndCount } = await findEndOfCentralDirectory(reader, rejectAmbiguousEndOfDirectory, maxAppendedDataSize);
|
|
5247
|
+
if (!endOfDirectoryInfo || (strictness == STRICTNESS_STRICT && endOfDirectoryReachingEndCount > 1)) {
|
|
5248
|
+
return false;
|
|
5249
|
+
}
|
|
5250
|
+
const commentLength = getUint16$1(getDataView(endOfDirectoryInfo), 20);
|
|
5251
|
+
const appendedDataOffset = endOfDirectoryInfo.offset + END_OF_CENTRAL_DIR_LENGTH + commentLength;
|
|
5252
|
+
return reader.size - appendedDataOffset <= maxAppendedDataSize;
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5184
5255
|
let ZipEntry$1 = class ZipEntry {
|
|
5185
5256
|
|
|
5186
5257
|
constructor(reader, options) {
|
|
@@ -5212,6 +5283,7 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5212
5283
|
dataDescriptor
|
|
5213
5284
|
} = bitFlag;
|
|
5214
5285
|
const localDirectory = fileEntry.localDirectory = {};
|
|
5286
|
+
const warnings = fileEntry.warnings = [];
|
|
5215
5287
|
const localHeaderOffset = getDiskOffset$1(reader, diskNumberStart) + offset;
|
|
5216
5288
|
const dataArray = await readUint8Array(reader, localHeaderOffset, HEADER_SIZE);
|
|
5217
5289
|
const dataView = getDataView(dataArray);
|
|
@@ -5252,10 +5324,10 @@ let ZipEntry$1 = class ZipEntry {
|
|
|
5252
5324
|
if (checkLocalFilename) {
|
|
5253
5325
|
localDirectory.rawFilename = rawLocalFilename;
|
|
5254
5326
|
}
|
|
5255
|
-
readCommonFooter(zipEntry, localDirectory, dataView, 4, true)
|
|
5256
|
-
|
|
5257
|
-
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5327
|
+
if (readCommonFooter(zipEntry, localDirectory, dataView, 4, true)) {
|
|
5328
|
+
addWarning(warnings, WARNING_MALFORMED_EXTRA_FIELD);
|
|
5258
5329
|
}
|
|
5330
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename, checkLocalDirectory ? UNDEFINED_VALUE : warnings);
|
|
5259
5331
|
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5260
5332
|
if (lastAccessDate) {
|
|
5261
5333
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
@@ -5481,6 +5553,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5481
5553
|
const extraField = directory.extraField = new Map();
|
|
5482
5554
|
const rawExtraFieldView = getDataView(rawExtraField);
|
|
5483
5555
|
let offsetExtraField = 0;
|
|
5556
|
+
let malformedExtraField = false;
|
|
5484
5557
|
try {
|
|
5485
5558
|
while (offsetExtraField < rawExtraField.length) {
|
|
5486
5559
|
const type = getUint16$1(rawExtraFieldView, offsetExtraField);
|
|
@@ -5492,7 +5565,10 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5492
5565
|
offsetExtraField += 4 + size;
|
|
5493
5566
|
}
|
|
5494
5567
|
} catch {
|
|
5495
|
-
|
|
5568
|
+
malformedExtraField = true;
|
|
5569
|
+
}
|
|
5570
|
+
if (offsetExtraField > rawExtraField.length) {
|
|
5571
|
+
malformedExtraField = true;
|
|
5496
5572
|
}
|
|
5497
5573
|
const compressionMethod = getUint16$1(dataView, offset + 4);
|
|
5498
5574
|
Object.assign(directory, {
|
|
@@ -5560,6 +5636,7 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5560
5636
|
if (extraFieldUSDZ) {
|
|
5561
5637
|
directory.extraFieldUSDZ = extraFieldUSDZ;
|
|
5562
5638
|
}
|
|
5639
|
+
return malformedExtraField;
|
|
5563
5640
|
}
|
|
5564
5641
|
|
|
5565
5642
|
function readExtraFieldZip64(extraFieldZip64, directory) {
|
|
@@ -6021,27 +6098,46 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
6021
6098
|
return UNDEFINED_VALUE;
|
|
6022
6099
|
}
|
|
6023
6100
|
|
|
6024
|
-
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
6101
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename, warnings) {
|
|
6025
6102
|
const { rawFilename } = zipEntry;
|
|
6103
|
+
const reject = !warnings;
|
|
6026
6104
|
const maskedLocalDirectory = zipEntry.decryptedDirectory &&
|
|
6027
6105
|
(localDirectory.rawBitFlag & BITFLAG_MASKED_LOCAL_HEADERS) == BITFLAG_MASKED_LOCAL_HEADERS;
|
|
6028
6106
|
if (checkLocalFilename && !maskedLocalDirectory &&
|
|
6029
6107
|
(rawLocalFilename.length != rawFilename.length ||
|
|
6030
6108
|
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
6031
|
-
|
|
6109
|
+
reportAmbiguity(reject, warnings, "mismatched local file header (filename)");
|
|
6032
6110
|
}
|
|
6033
6111
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
6034
|
-
|
|
6112
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG);
|
|
6035
6113
|
}
|
|
6036
6114
|
if (localDirectory.compressionMethod != zipEntry.compressionMethod) {
|
|
6037
|
-
|
|
6115
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD);
|
|
6038
6116
|
}
|
|
6039
6117
|
if (!localDirectory.bitFlag.dataDescriptor && !maskedLocalDirectory &&
|
|
6040
6118
|
(localDirectory.crc32 || localDirectory.compressedSize || localDirectory.uncompressedSize) &&
|
|
6041
6119
|
(localDirectory.crc32 != zipEntry.crc32 ||
|
|
6042
6120
|
localDirectory.compressedSize != zipEntry.compressedSize ||
|
|
6043
6121
|
localDirectory.uncompressedSize != zipEntry.uncompressedSize)) {
|
|
6044
|
-
|
|
6122
|
+
reportAmbiguity(reject, warnings, WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES);
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
|
|
6126
|
+
function reportAmbiguity(reject, warnings, reason) {
|
|
6127
|
+
if (reject) {
|
|
6128
|
+
throwAmbiguousArchive(reason);
|
|
6129
|
+
} else {
|
|
6130
|
+
addWarning(warnings, reason);
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
|
|
6134
|
+
function addWarning(warnings, reason, filename) {
|
|
6135
|
+
if (!warnings.some(warning => warning.reason == reason)) {
|
|
6136
|
+
const warning = { reason };
|
|
6137
|
+
if (filename !== UNDEFINED_VALUE) {
|
|
6138
|
+
warning.filename = filename;
|
|
6139
|
+
}
|
|
6140
|
+
warnings.push(warning);
|
|
6045
6141
|
}
|
|
6046
6142
|
}
|
|
6047
6143
|
|
|
@@ -6118,8 +6214,23 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
6118
6214
|
ERR_UNSUPPORTED_ENCRYPTION: ERR_UNSUPPORTED_ENCRYPTION,
|
|
6119
6215
|
ERR_UNSUPPORTED_UINT64: ERR_UNSUPPORTED_UINT64,
|
|
6120
6216
|
ERR_WORKER_STARTUP_TIMEOUT: ERR_WORKER_STARTUP_TIMEOUT,
|
|
6217
|
+
WARNING_APPENDED_DATA: WARNING_APPENDED_DATA,
|
|
6218
|
+
WARNING_COMPRESSED_PATCHED_DATA: WARNING_COMPRESSED_PATCHED_DATA,
|
|
6219
|
+
WARNING_DUPLICATE_FILENAME: WARNING_DUPLICATE_FILENAME,
|
|
6220
|
+
WARNING_MALFORMED_EXTRA_FIELD: WARNING_MALFORMED_EXTRA_FIELD,
|
|
6221
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG: WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG,
|
|
6222
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD: WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD,
|
|
6223
|
+
WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES: WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES,
|
|
6224
|
+
WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY: WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY,
|
|
6225
|
+
WARNING_PREPENDED_DATA: WARNING_PREPENDED_DATA,
|
|
6226
|
+
WARNING_TRAILING_CENTRAL_DIRECTORY_DATA: WARNING_TRAILING_CENTRAL_DIRECTORY_DATA,
|
|
6227
|
+
WARNING_UNKNOWN_VERSION: WARNING_UNKNOWN_VERSION,
|
|
6228
|
+
WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA: WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA,
|
|
6229
|
+
WARNING_UNSORTED_CENTRAL_DIRECTORY: WARNING_UNSORTED_CENTRAL_DIRECTORY,
|
|
6230
|
+
WARNING_WRAPPED_ENTRIES_COUNT: WARNING_WRAPPED_ENTRIES_COUNT,
|
|
6121
6231
|
ZipReader: ZipReader,
|
|
6122
|
-
ZipReaderStream: ZipReaderStream
|
|
6232
|
+
ZipReaderStream: ZipReaderStream,
|
|
6233
|
+
isZipFile: isZipFile
|
|
6123
6234
|
});
|
|
6124
6235
|
|
|
6125
6236
|
/*
|
|
@@ -6332,6 +6443,7 @@ class ZipWriter {
|
|
|
6332
6443
|
rawExtraFieldNTFS: EMPTY_UINT8_ARRAY,
|
|
6333
6444
|
rawExtraFieldUnix: EMPTY_UINT8_ARRAY,
|
|
6334
6445
|
rawExtraField,
|
|
6446
|
+
rawCentralExtraField: EMPTY_UINT8_ARRAY,
|
|
6335
6447
|
extendedTimestamp: false,
|
|
6336
6448
|
headerArray,
|
|
6337
6449
|
headerView
|
|
@@ -6505,7 +6617,6 @@ async function prependZipEntries(zipWriter, reader) {
|
|
|
6505
6617
|
|
|
6506
6618
|
async function addFileEntry(zipWriter, name, reader, options) {
|
|
6507
6619
|
options = Object.assign({}, options);
|
|
6508
|
-
name = name.trim();
|
|
6509
6620
|
if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
6510
6621
|
name += DIRECTORY_SIGNATURE;
|
|
6511
6622
|
}
|
|
@@ -6596,7 +6707,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6596
6707
|
}
|
|
6597
6708
|
|
|
6598
6709
|
function resolveAttributes(zipWriter, name, options) {
|
|
6599
|
-
name = name.trim();
|
|
6600
6710
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6601
6711
|
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6602
6712
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
@@ -6801,6 +6911,7 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6801
6911
|
}
|
|
6802
6912
|
const rawExtraField = serializeExtraField(options[PROPERTY_NAME_EXTRA_FIELD]);
|
|
6803
6913
|
const rawLocalExtraField = serializeExtraField(options[OPTION_LOCAL_EXTRA_FIELD]);
|
|
6914
|
+
const rawCentralExtraField = serializeExtraField(options[OPTION_CENTRAL_EXTRA_FIELD]);
|
|
6804
6915
|
return {
|
|
6805
6916
|
comment,
|
|
6806
6917
|
resolvedOptions: {
|
|
@@ -6836,7 +6947,8 @@ function resolveMetadata(zipWriter, name, options) {
|
|
|
6836
6947
|
dataDescriptor,
|
|
6837
6948
|
zip64,
|
|
6838
6949
|
rawExtraField,
|
|
6839
|
-
rawLocalExtraField
|
|
6950
|
+
rawLocalExtraField,
|
|
6951
|
+
rawCentralExtraField
|
|
6840
6952
|
}
|
|
6841
6953
|
};
|
|
6842
6954
|
}
|
|
@@ -6978,7 +7090,6 @@ async function getEntriesSize(writerOptions, entries, writeOrderGuaranteed, comm
|
|
|
6978
7090
|
let { name } = entry;
|
|
6979
7091
|
const { size } = entry;
|
|
6980
7092
|
const options = Object.assign({}, entry.options);
|
|
6981
|
-
name = name.trim();
|
|
6982
7093
|
if (getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY) && !name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
6983
7094
|
name += DIRECTORY_SIGNATURE;
|
|
6984
7095
|
}
|
|
@@ -7234,6 +7345,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7234
7345
|
versionMadeBy,
|
|
7235
7346
|
rawComment,
|
|
7236
7347
|
rawExtraField,
|
|
7348
|
+
rawCentralExtraField,
|
|
7237
7349
|
useWebWorkers,
|
|
7238
7350
|
transferStreams,
|
|
7239
7351
|
onstart,
|
|
@@ -7277,6 +7389,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lockFileEntry
|
|
|
7277
7389
|
rawExtraFieldUnix,
|
|
7278
7390
|
rawExtraFieldAES,
|
|
7279
7391
|
rawExtraField,
|
|
7392
|
+
rawCentralExtraField,
|
|
7280
7393
|
extendedTimestamp,
|
|
7281
7394
|
msDosCompatible,
|
|
7282
7395
|
internalFileAttributes,
|
|
@@ -7777,6 +7890,7 @@ function createDirectoryRecords(files) {
|
|
|
7777
7890
|
rawExtraFieldNTFS,
|
|
7778
7891
|
rawExtraFieldUnix,
|
|
7779
7892
|
rawExtraField,
|
|
7893
|
+
rawCentralExtraField,
|
|
7780
7894
|
extendedTimestamp,
|
|
7781
7895
|
extraFieldExtendedTimestampFlag,
|
|
7782
7896
|
lastModDate,
|
|
@@ -7831,7 +7945,8 @@ function createDirectoryRecords(files) {
|
|
|
7831
7945
|
rawExtraFieldNTFS,
|
|
7832
7946
|
rawExtraFieldUnix,
|
|
7833
7947
|
rawExtraFieldTimestamp,
|
|
7834
|
-
rawExtraField
|
|
7948
|
+
rawExtraField,
|
|
7949
|
+
rawCentralExtraField);
|
|
7835
7950
|
if (extraFieldLength > MAX_16_BITS) {
|
|
7836
7951
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
7837
7952
|
}
|
|
@@ -7859,6 +7974,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7859
7974
|
rawExtraFieldNTFS,
|
|
7860
7975
|
rawExtraFieldUnix,
|
|
7861
7976
|
rawExtraField,
|
|
7977
|
+
rawCentralExtraField,
|
|
7862
7978
|
rawComment,
|
|
7863
7979
|
versionMadeBy,
|
|
7864
7980
|
headerArray,
|
|
@@ -7873,7 +7989,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7873
7989
|
uncompressedSize,
|
|
7874
7990
|
compressedSize
|
|
7875
7991
|
} = fileEntry;
|
|
7876
|
-
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField);
|
|
7992
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraFieldUnix, rawExtraField, rawCentralExtraField);
|
|
7877
7993
|
const directoryRecordLength = CENTRAL_FILE_HEADER_LENGTH + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
7878
7994
|
if (exceedsAvailableSize(writer, offset + directoryRecordLength - directoryDiskOffset)) {
|
|
7879
7995
|
await writeData(writer, directoryArray.slice(directoryDiskOffset, offset));
|
|
@@ -7911,6 +8027,7 @@ async function writeDirectoryRecords(zipWriter, directoryDataLength, options) {
|
|
|
7911
8027
|
directoryRecord.writeBytes(rawExtraFieldNTFS);
|
|
7912
8028
|
directoryRecord.writeBytes(rawExtraFieldUnix);
|
|
7913
8029
|
directoryRecord.writeBytes(rawExtraField);
|
|
8030
|
+
directoryRecord.writeBytes(rawCentralExtraField);
|
|
7914
8031
|
directoryRecord.writeBytes(rawComment);
|
|
7915
8032
|
arraySet(directoryArray, directoryRecord.array, offset);
|
|
7916
8033
|
offset += directoryRecordLength;
|
|
@@ -10735,6 +10852,20 @@ exports.TextReader = TextReader;
|
|
|
10735
10852
|
exports.TextWriter = TextWriter;
|
|
10736
10853
|
exports.Uint8ArrayReader = Uint8ArrayReader;
|
|
10737
10854
|
exports.Uint8ArrayWriter = Uint8ArrayWriter;
|
|
10855
|
+
exports.WARNING_APPENDED_DATA = WARNING_APPENDED_DATA;
|
|
10856
|
+
exports.WARNING_COMPRESSED_PATCHED_DATA = WARNING_COMPRESSED_PATCHED_DATA;
|
|
10857
|
+
exports.WARNING_DUPLICATE_FILENAME = WARNING_DUPLICATE_FILENAME;
|
|
10858
|
+
exports.WARNING_MALFORMED_EXTRA_FIELD = WARNING_MALFORMED_EXTRA_FIELD;
|
|
10859
|
+
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG = WARNING_MISMATCHED_LOCAL_FILE_HEADER_BIT_FLAG;
|
|
10860
|
+
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD = WARNING_MISMATCHED_LOCAL_FILE_HEADER_COMPRESSION_METHOD;
|
|
10861
|
+
exports.WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES = WARNING_MISMATCHED_LOCAL_FILE_HEADER_CRC32_OR_SIZES;
|
|
10862
|
+
exports.WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY = WARNING_MISMATCHED_ZIP64_END_OF_CENTRAL_DIRECTORY;
|
|
10863
|
+
exports.WARNING_PREPENDED_DATA = WARNING_PREPENDED_DATA;
|
|
10864
|
+
exports.WARNING_TRAILING_CENTRAL_DIRECTORY_DATA = WARNING_TRAILING_CENTRAL_DIRECTORY_DATA;
|
|
10865
|
+
exports.WARNING_UNKNOWN_VERSION = WARNING_UNKNOWN_VERSION;
|
|
10866
|
+
exports.WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA = WARNING_UNKNOWN_ZIP64_EXTENSIBLE_DATA;
|
|
10867
|
+
exports.WARNING_UNSORTED_CENTRAL_DIRECTORY = WARNING_UNSORTED_CENTRAL_DIRECTORY;
|
|
10868
|
+
exports.WARNING_WRAPPED_ENTRIES_COUNT = WARNING_WRAPPED_ENTRIES_COUNT;
|
|
10738
10869
|
exports.Writer = Writer;
|
|
10739
10870
|
exports.ZipDirectoryEntry = ZipDirectoryEntry;
|
|
10740
10871
|
exports.ZipEntry = ZipEntry;
|
|
@@ -10750,6 +10881,7 @@ exports.createOPFSTempStream = createOPFSTempStream;
|
|
|
10750
10881
|
exports.createSyncAccessHandleTempStream = createSyncAccessHandleTempStream;
|
|
10751
10882
|
exports.fs = fs;
|
|
10752
10883
|
exports.getMimeType = getMimeType;
|
|
10884
|
+
exports.isZipFile = isZipFile;
|
|
10753
10885
|
exports.registerCodec = registerCodec;
|
|
10754
10886
|
exports.resetConfiguration = resetConfiguration;
|
|
10755
10887
|
exports.terminateWorkers = terminateWorkersAndModule;
|