@zip.js/zip.js 2.8.52 → 2.8.53
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 +154 -52
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +154 -51
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +157 -52
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +143 -47
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +157 -52
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +157 -51
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +157 -51
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +154 -51
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +154 -51
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +154 -51
- package/dist/zip.min.js +1 -1
- package/eslint.config.mjs +1 -1
- package/index-native.cjs +157 -51
- package/index-native.min.js +1 -1
- package/index.cjs +157 -51
- package/index.d.cts +278 -40
- package/index.d.ts +278 -40
- package/index.min.js +1 -1
- package/lib/core/codec-worker-web.js +13 -4
- package/lib/core/constants.js +5 -0
- package/lib/core/io.js +11 -2
- package/lib/core/options.js +2 -0
- package/lib/core/zip-entry.js +8 -0
- package/lib/core/zip-reader.js +91 -34
- package/lib/core/zip-writer.js +36 -12
- package/lib/zip-core-writer.js +1 -0
- package/package.json +5 -3
package/deno.json
CHANGED
|
@@ -93,6 +93,9 @@ const VERSION_DEFLATE = 0x14;
|
|
|
93
93
|
const VERSION_ZIP64 = 0x2D;
|
|
94
94
|
const VERSION_AES = 0x33;
|
|
95
95
|
|
|
96
|
+
const VERSION_MADE_BY_MSDOS = 0x0014;
|
|
97
|
+
const VERSION_MADE_BY_UNIX = 0x0300;
|
|
98
|
+
|
|
96
99
|
const DIRECTORY_SIGNATURE = "/";
|
|
97
100
|
|
|
98
101
|
const HEADER_SIZE = 30;
|
|
@@ -2787,6 +2790,7 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2787
2790
|
worker,
|
|
2788
2791
|
workerAlive: false,
|
|
2789
2792
|
terminated: false,
|
|
2793
|
+
startupError: null,
|
|
2790
2794
|
interface: {
|
|
2791
2795
|
run: async () => {
|
|
2792
2796
|
try {
|
|
@@ -2814,6 +2818,13 @@ function createWebWorkerInterface(workerData, config) {
|
|
|
2814
2818
|
}
|
|
2815
2819
|
|
|
2816
2820
|
async function runWebWorker(workerData, config) {
|
|
2821
|
+
if (!workerData.worker) {
|
|
2822
|
+
const { startupError } = workerData;
|
|
2823
|
+
workerData.startupError = null;
|
|
2824
|
+
const error = startupError || new Error(ERR_WORKER_STARTUP_TIMEOUT);
|
|
2825
|
+
error.workerStartupFailed = true;
|
|
2826
|
+
throw error;
|
|
2827
|
+
}
|
|
2817
2828
|
let resolveResult, rejectResult;
|
|
2818
2829
|
const result = new Promise((resolve, reject) => {
|
|
2819
2830
|
resolveResult = resolve;
|
|
@@ -3027,11 +3038,12 @@ function onWorkerError(event, workerData) {
|
|
|
3027
3038
|
if (!workerAlive) {
|
|
3028
3039
|
workerData.worker = null;
|
|
3029
3040
|
}
|
|
3041
|
+
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3042
|
+
if (!workerAlive) {
|
|
3043
|
+
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3044
|
+
workerData.startupError = error;
|
|
3045
|
+
}
|
|
3030
3046
|
if (rejectResult) {
|
|
3031
|
-
let error = event.error || new Error(event.message || ERROR_EVENT_TYPE);
|
|
3032
|
-
if (!workerAlive) {
|
|
3033
|
-
error = Object.assign(new Error(error.message || ERROR_EVENT_TYPE), { workerStartupFailed: true });
|
|
3034
|
-
}
|
|
3035
3047
|
rejectResult(error);
|
|
3036
3048
|
if (writer) {
|
|
3037
3049
|
writer.releaseLock();
|
|
@@ -4060,9 +4072,8 @@ class SplitDataReader extends Reader {
|
|
|
4060
4072
|
|
|
4061
4073
|
async init() {
|
|
4062
4074
|
const reader = this;
|
|
4063
|
-
const { readers } = reader;
|
|
4064
4075
|
reader.lastDiskNumber = 0;
|
|
4065
|
-
await Promise.all(readers.map(
|
|
4076
|
+
const readers = reader.readers = await Promise.all(reader.readers.map(initDiskReader));
|
|
4066
4077
|
reader.diskOffsets = readers.map(diskReader => {
|
|
4067
4078
|
const diskOffset = reader.size;
|
|
4068
4079
|
reader.size += diskReader.size;
|
|
@@ -4257,6 +4268,16 @@ async function initStream(stream, initSize) {
|
|
|
4257
4268
|
}
|
|
4258
4269
|
}
|
|
4259
4270
|
|
|
4271
|
+
async function initDiskReader(diskReader) {
|
|
4272
|
+
diskReader = new GenericReader(diskReader);
|
|
4273
|
+
await initStream(diskReader);
|
|
4274
|
+
if (diskReader.size === UNDEFINED_VALUE || !diskReader.readUint8Array) {
|
|
4275
|
+
diskReader = new BlobReader(await streamToBlob(diskReader.readable));
|
|
4276
|
+
await initStream(diskReader);
|
|
4277
|
+
}
|
|
4278
|
+
return diskReader;
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4260
4281
|
function readUint8Array(reader, offset, size) {
|
|
4261
4282
|
return reader.readUint8Array(offset, size);
|
|
4262
4283
|
}
|
|
@@ -4415,6 +4436,10 @@ const PROPERTY_NAME_SETUID = "setuid";
|
|
|
4415
4436
|
const PROPERTY_NAME_SETGID = "setgid";
|
|
4416
4437
|
const PROPERTY_NAME_STICKY = "sticky";
|
|
4417
4438
|
const PROPERTY_NAME_BITFLAG = "bitFlag";
|
|
4439
|
+
const PROPERTY_NAME_RAW_BITFLAG = "rawBitFlag";
|
|
4440
|
+
const PROPERTY_NAME_FILENAME_LENGTH = "filenameLength";
|
|
4441
|
+
const PROPERTY_NAME_EXTRA_FIELD_LENGTH = "extraFieldLength";
|
|
4442
|
+
const PROPERTY_NAME_UNIX_EXTERNAL_UPPER = "unixExternalUpper";
|
|
4418
4443
|
const PROPERTY_NAME_FILENAME_UTF8 = "filenameUTF8";
|
|
4419
4444
|
const PROPERTY_NAME_COMMENT_UTF8 = "commentUTF8";
|
|
4420
4445
|
const PROPERTY_NAME_RAW_EXTRA_FIELD = "rawExtraField";
|
|
@@ -4467,10 +4492,14 @@ const PROPERTY_NAMES = [
|
|
|
4467
4492
|
PROPERTY_NAME_UID,
|
|
4468
4493
|
PROPERTY_NAME_GID,
|
|
4469
4494
|
PROPERTY_NAME_UNIX_MODE,
|
|
4495
|
+
PROPERTY_NAME_UNIX_EXTERNAL_UPPER,
|
|
4470
4496
|
PROPERTY_NAME_SETUID,
|
|
4471
4497
|
PROPERTY_NAME_SETGID,
|
|
4472
4498
|
PROPERTY_NAME_STICKY,
|
|
4473
4499
|
PROPERTY_NAME_BITFLAG,
|
|
4500
|
+
PROPERTY_NAME_RAW_BITFLAG,
|
|
4501
|
+
PROPERTY_NAME_FILENAME_LENGTH,
|
|
4502
|
+
PROPERTY_NAME_EXTRA_FIELD_LENGTH,
|
|
4474
4503
|
PROPERTY_NAME_FILENAME_UTF8,
|
|
4475
4504
|
PROPERTY_NAME_COMMENT_UTF8,
|
|
4476
4505
|
PROPERTY_NAME_RAW_EXTRA_FIELD,
|
|
@@ -4532,6 +4561,7 @@ const OPTION_CHECK_PASSWORD_ONLY = "checkPasswordOnly";
|
|
|
4532
4561
|
const OPTION_CHECK_OVERLAPPING_ENTRY_ONLY = "checkOverlappingEntryOnly";
|
|
4533
4562
|
const OPTION_CHECK_OVERLAPPING_ENTRY = "checkOverlappingEntry";
|
|
4534
4563
|
const OPTION_CHECK_AMBIGUITY = "checkAmbiguity";
|
|
4564
|
+
const OPTION_CHECK_LOCAL_DIRECTORY = "checkLocalDirectory";
|
|
4535
4565
|
const OPTION_CHECK_SIGNATURE = "checkSignature";
|
|
4536
4566
|
const OPTION_CHECK_CRC32 = "checkCrc32";
|
|
4537
4567
|
const OPTION_CHECK_AUTHENTICATION_CODE = "checkAuthenticationCode";
|
|
@@ -4663,7 +4693,7 @@ class ZipReader {
|
|
|
4663
4693
|
if (reader.size < END_OF_CENTRAL_DIR_LENGTH) {
|
|
4664
4694
|
throw new Error(ERR_BAD_FORMAT);
|
|
4665
4695
|
}
|
|
4666
|
-
const strictness = getStrictness(
|
|
4696
|
+
const strictness = getStrictness(options, zipReader.options);
|
|
4667
4697
|
const checkAmbiguity = strictness == STRICTNESS_STRICT;
|
|
4668
4698
|
const rejectAmbiguousEndOfDirectory = strictness != STRICTNESS_TOLERANT;
|
|
4669
4699
|
const maxAppendedDataSize = getMaxAppendedDataSize(getOptionValue$1(zipReader, options, OPTION_MAX_APPENDED_DATA_SIZE), strictness);
|
|
@@ -4885,6 +4915,7 @@ class ZipReader {
|
|
|
4885
4915
|
index: indexFile,
|
|
4886
4916
|
versionMadeBy,
|
|
4887
4917
|
msDosCompatible,
|
|
4918
|
+
zip64: false,
|
|
4888
4919
|
compressedSize: 0,
|
|
4889
4920
|
uncompressedSize: 0,
|
|
4890
4921
|
commentLength,
|
|
@@ -5095,9 +5126,12 @@ class ZipEntry {
|
|
|
5095
5126
|
extraFieldLength,
|
|
5096
5127
|
filenameLength
|
|
5097
5128
|
} = localDirectory;
|
|
5098
|
-
const
|
|
5129
|
+
const checkLocalDirectoryOption = getOptionValue$1(zipEntry, options, OPTION_CHECK_LOCAL_DIRECTORY);
|
|
5130
|
+
const entryStrictness = getStrictness(options, zipEntry.options);
|
|
5131
|
+
const checkLocalDirectory = getCheckLocalDirectory(checkLocalDirectoryOption, entryStrictness);
|
|
5132
|
+
const checkLocalFilename = getCheckLocalFilename(checkLocalDirectoryOption, entryStrictness);
|
|
5099
5133
|
let rawLocalFilename = EMPTY_UINT8_ARRAY;
|
|
5100
|
-
if (
|
|
5134
|
+
if (checkLocalFilename && (filenameLength || extraFieldLength)) {
|
|
5101
5135
|
const trailingDataArray = await readUint8Array(reader, localHeaderOffset + HEADER_SIZE, filenameLength + extraFieldLength);
|
|
5102
5136
|
rawLocalFilename = trailingDataArray.subarray(0, filenameLength);
|
|
5103
5137
|
localDirectory.rawExtraField = trailingDataArray.subarray(filenameLength);
|
|
@@ -5106,17 +5140,26 @@ class ZipEntry {
|
|
|
5106
5140
|
await readUint8Array(reader, localHeaderOffset + HEADER_SIZE + filenameLength, extraFieldLength) :
|
|
5107
5141
|
EMPTY_UINT8_ARRAY;
|
|
5108
5142
|
}
|
|
5143
|
+
if (checkLocalFilename) {
|
|
5144
|
+
localDirectory.rawFilename = rawLocalFilename;
|
|
5145
|
+
}
|
|
5109
5146
|
readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
|
|
5110
|
-
if (
|
|
5111
|
-
|
|
5147
|
+
if (checkLocalDirectory) {
|
|
5148
|
+
validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename);
|
|
5112
5149
|
}
|
|
5113
|
-
const { lastAccessDate, creationDate } = localDirectory;
|
|
5150
|
+
const { lastAccessDate, creationDate, uid, gid } = localDirectory;
|
|
5114
5151
|
if (lastAccessDate) {
|
|
5115
5152
|
fileEntry.lastAccessDate = lastAccessDate;
|
|
5116
5153
|
}
|
|
5117
5154
|
if (creationDate) {
|
|
5118
5155
|
fileEntry.creationDate = creationDate;
|
|
5119
5156
|
}
|
|
5157
|
+
if (uid !== UNDEFINED_VALUE && fileEntry.uid === UNDEFINED_VALUE) {
|
|
5158
|
+
fileEntry.uid = uid;
|
|
5159
|
+
}
|
|
5160
|
+
if (gid !== UNDEFINED_VALUE && fileEntry.gid === UNDEFINED_VALUE) {
|
|
5161
|
+
fileEntry.gid = gid;
|
|
5162
|
+
}
|
|
5120
5163
|
const encrypted = zipEntry.encrypted && localDirectory.encrypted && !passThrough;
|
|
5121
5164
|
const zipCrypto = encrypted && !extraFieldAES;
|
|
5122
5165
|
if (!passThrough) {
|
|
@@ -5352,10 +5395,12 @@ function readCommonFooter(fileEntry, directory, dataView, offset, localDirectory
|
|
|
5352
5395
|
directory.extraFieldNTFS = extraFieldNTFS;
|
|
5353
5396
|
}
|
|
5354
5397
|
const extraFieldUnix = extraField.get(EXTRAFIELD_TYPE_UNIX);
|
|
5398
|
+
let unixIdsRead;
|
|
5355
5399
|
if (extraFieldUnix) {
|
|
5356
|
-
readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5400
|
+
unixIdsRead = readExtraFieldUnix(extraFieldUnix, directory, false);
|
|
5357
5401
|
directory.extraFieldUnix = extraFieldUnix;
|
|
5358
|
-
}
|
|
5402
|
+
}
|
|
5403
|
+
if (!unixIdsRead) {
|
|
5359
5404
|
const extraFieldInfoZip = extraField.get(EXTRAFIELD_TYPE_INFOZIP);
|
|
5360
5405
|
if (extraFieldInfoZip) {
|
|
5361
5406
|
readExtraFieldUnix(extraFieldInfoZip, directory, true);
|
|
@@ -5458,7 +5503,7 @@ function readExtraFieldNTFS(extraFieldNTFS, directory) {
|
|
|
5458
5503
|
const creationDate = getDateNTFS(rawCreationDate);
|
|
5459
5504
|
const extraFieldData = { lastModDate, lastAccessDate, creationDate };
|
|
5460
5505
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
5461
|
-
Object.assign(directory, extraFieldData);
|
|
5506
|
+
Object.assign(directory, extraFieldData, { rawLastAccessDate, rawCreationDate });
|
|
5462
5507
|
}
|
|
5463
5508
|
}
|
|
5464
5509
|
|
|
@@ -5502,6 +5547,7 @@ function readExtraFieldUnix(extraField, directory, isInfoZip) {
|
|
|
5502
5547
|
if (gid !== UNDEFINED_VALUE) {
|
|
5503
5548
|
directory.gid = gid;
|
|
5504
5549
|
}
|
|
5550
|
+
return uid !== UNDEFINED_VALUE || gid !== UNDEFINED_VALUE;
|
|
5505
5551
|
} catch {
|
|
5506
5552
|
// ignored
|
|
5507
5553
|
}
|
|
@@ -5574,26 +5620,25 @@ async function detectOverlappingEntry({
|
|
|
5574
5620
|
}
|
|
5575
5621
|
if (dataDescriptorLength) {
|
|
5576
5622
|
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
5577
|
-
const
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
if (extraFieldZip64) {
|
|
5584
|
-
readCompressedSize = getBigUint64(getDataView(dataDescriptorArray), 8);
|
|
5585
|
-
readUncompressedSize = getBigUint64(getDataView(dataDescriptorArray), 16);
|
|
5586
|
-
} else {
|
|
5587
|
-
readCompressedSize = getUint32(getDataView(dataDescriptorArray), 8);
|
|
5588
|
-
readUncompressedSize = getUint32(getDataView(dataDescriptorArray), 12);
|
|
5589
|
-
}
|
|
5590
|
-
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || readCrc32 == crc32;
|
|
5623
|
+
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
5624
|
+
let signature = dataDescriptorArray.length == dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH &&
|
|
5625
|
+
getUint32(dataDescriptorView, 0) == DATA_DESCRIPTOR_RECORD_SIGNATURE;
|
|
5626
|
+
if (signature) {
|
|
5627
|
+
const signedDataDescriptor = readDataDescriptor(dataDescriptorView, DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH, extraFieldZip64);
|
|
5628
|
+
const matchCrc32 = (fileEntry.encrypted && !fileEntry.zipCrypto) || signedDataDescriptor.crc32 == crc32;
|
|
5591
5629
|
if (matchCrc32 &&
|
|
5592
|
-
|
|
5593
|
-
|
|
5630
|
+
signedDataDescriptor.compressedSize == compressedSize &&
|
|
5631
|
+
signedDataDescriptor.uncompressedSize == uncompressedSize) {
|
|
5594
5632
|
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
5633
|
+
} else {
|
|
5634
|
+
signature = false;
|
|
5595
5635
|
}
|
|
5596
5636
|
}
|
|
5637
|
+
if (dataDescriptorArray.length >= dataDescriptorLength) {
|
|
5638
|
+
const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
|
|
5639
|
+
localDataDescriptor.signature = signature;
|
|
5640
|
+
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
5641
|
+
}
|
|
5597
5642
|
}
|
|
5598
5643
|
const range = {
|
|
5599
5644
|
start: offset,
|
|
@@ -5610,6 +5655,20 @@ async function detectOverlappingEntry({
|
|
|
5610
5655
|
readRanges.set(index, range);
|
|
5611
5656
|
}
|
|
5612
5657
|
|
|
5658
|
+
function readDataDescriptor(dataDescriptorView, offset, extraFieldZip64) {
|
|
5659
|
+
const crc32 = getUint32(dataDescriptorView, offset);
|
|
5660
|
+
let compressedSize;
|
|
5661
|
+
let uncompressedSize;
|
|
5662
|
+
if (extraFieldZip64) {
|
|
5663
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
5664
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
5665
|
+
} else {
|
|
5666
|
+
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
5667
|
+
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
5668
|
+
}
|
|
5669
|
+
return { crc32, compressedSize, uncompressedSize };
|
|
5670
|
+
}
|
|
5671
|
+
|
|
5613
5672
|
function getDiskOffset$1(reader, diskNumber) {
|
|
5614
5673
|
return reader.getDiskOffset ? reader.getDiskOffset(diskNumber) : 0;
|
|
5615
5674
|
}
|
|
@@ -5618,14 +5677,40 @@ function isStrictnessValue(value) {
|
|
|
5618
5677
|
return value === STRICTNESS_STRICT || value === STRICTNESS_BALANCED || value === STRICTNESS_TOLERANT;
|
|
5619
5678
|
}
|
|
5620
5679
|
|
|
5621
|
-
function getStrictness(
|
|
5622
|
-
|
|
5623
|
-
|
|
5680
|
+
function getStrictness(options, inheritedOptions) {
|
|
5681
|
+
return resolveStrictness(options, resolveStrictness(inheritedOptions, STRICTNESS_BALANCED));
|
|
5682
|
+
}
|
|
5683
|
+
|
|
5684
|
+
function resolveStrictness(options, inheritedStrictness) {
|
|
5685
|
+
const strictness = options[OPTION_STRICTNESS];
|
|
5686
|
+
if (strictness !== UNDEFINED_VALUE) {
|
|
5687
|
+
if (!isStrictnessValue(strictness)) {
|
|
5688
|
+
throw new Error(ERR_INVALID_STRICTNESS);
|
|
5689
|
+
}
|
|
5690
|
+
return strictness;
|
|
5691
|
+
}
|
|
5692
|
+
const checkAmbiguity = options[OPTION_CHECK_AMBIGUITY];
|
|
5693
|
+
if (checkAmbiguity === UNDEFINED_VALUE) {
|
|
5694
|
+
return inheritedStrictness;
|
|
5695
|
+
}
|
|
5696
|
+
if (checkAmbiguity) {
|
|
5697
|
+
return STRICTNESS_STRICT;
|
|
5698
|
+
}
|
|
5699
|
+
return inheritedStrictness == STRICTNESS_TOLERANT ? STRICTNESS_TOLERANT : STRICTNESS_BALANCED;
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
function getCheckLocalDirectory(checkLocalDirectory, strictness) {
|
|
5703
|
+
if (checkLocalDirectory === UNDEFINED_VALUE) {
|
|
5704
|
+
return strictness != STRICTNESS_TOLERANT;
|
|
5624
5705
|
}
|
|
5625
|
-
|
|
5626
|
-
|
|
5706
|
+
return Boolean(checkLocalDirectory);
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
function getCheckLocalFilename(checkLocalFilename, strictness) {
|
|
5710
|
+
if (checkLocalFilename === UNDEFINED_VALUE) {
|
|
5711
|
+
return strictness == STRICTNESS_STRICT;
|
|
5627
5712
|
}
|
|
5628
|
-
return
|
|
5713
|
+
return Boolean(checkLocalFilename);
|
|
5629
5714
|
}
|
|
5630
5715
|
|
|
5631
5716
|
function getFilenameValidation(filenameValidation, strictness) {
|
|
@@ -5773,10 +5858,11 @@ async function readSignature(reader, view, anchoredOffset, signatureOffset, size
|
|
|
5773
5858
|
return UNDEFINED_VALUE;
|
|
5774
5859
|
}
|
|
5775
5860
|
|
|
5776
|
-
function
|
|
5861
|
+
function validateLocalDirectory(zipEntry, localDirectory, rawLocalFilename, checkLocalFilename) {
|
|
5777
5862
|
const { rawFilename } = zipEntry;
|
|
5778
|
-
if (
|
|
5779
|
-
rawLocalFilename.
|
|
5863
|
+
if (checkLocalFilename &&
|
|
5864
|
+
(rawLocalFilename.length != rawFilename.length ||
|
|
5865
|
+
rawLocalFilename.some((byteValue, indexByte) => byteValue != rawFilename[indexByte]))) {
|
|
5780
5866
|
throwAmbiguousArchive("mismatched local file header (filename)");
|
|
5781
5867
|
}
|
|
5782
5868
|
if ((localDirectory.rawBitFlag & BITFLAG_AMBIGUITY_MASK) != (zipEntry.rawBitFlag & BITFLAG_AMBIGUITY_MASK)) {
|
|
@@ -5894,6 +5980,7 @@ var zipReader = /*#__PURE__*/Object.freeze({
|
|
|
5894
5980
|
|
|
5895
5981
|
const ERR_DUPLICATED_NAME = "File already exists";
|
|
5896
5982
|
const ERR_INVALID_COMMENT = "Zip file comment exceeds 64KB";
|
|
5983
|
+
const ERR_INVALID_COMMENT_TYPE = "Invalid zip file comment (must be a Uint8Array)";
|
|
5897
5984
|
const ERR_INVALID_ENTRY_COMMENT = "File entry comment exceeds 64KB";
|
|
5898
5985
|
const ERR_INVALID_ENTRY_NAME = "File entry name exceeds 64KB";
|
|
5899
5986
|
const ERR_INVALID_VERSION = "Version exceeds 65535";
|
|
@@ -5962,6 +6049,10 @@ class ZipWriter {
|
|
|
5962
6049
|
}
|
|
5963
6050
|
reader = new GenericReader(reader);
|
|
5964
6051
|
await initStream(reader);
|
|
6052
|
+
if (reader.size === UNDEFINED_VALUE || !reader.readUint8Array) {
|
|
6053
|
+
reader = new BlobReader(await streamToBlob(reader.readable));
|
|
6054
|
+
await initStream(reader);
|
|
6055
|
+
}
|
|
5965
6056
|
const { ZipReader } = await Promise.resolve().then(function () { return zipReader; });
|
|
5966
6057
|
const zipReader$1 = new ZipReader(reader.readable);
|
|
5967
6058
|
const entries = await zipReader$1.getEntries();
|
|
@@ -6110,6 +6201,9 @@ class ZipWriter {
|
|
|
6110
6201
|
const zipWriter = this;
|
|
6111
6202
|
const { pendingAddFileCalls, writer } = this;
|
|
6112
6203
|
const { writable } = writer;
|
|
6204
|
+
if (!(comment instanceof Uint8Array)) {
|
|
6205
|
+
throw new Error(ERR_INVALID_COMMENT_TYPE);
|
|
6206
|
+
}
|
|
6113
6207
|
if (getLength(comment) > MAX_16_BITS) {
|
|
6114
6208
|
throw new Error(ERR_INVALID_COMMENT);
|
|
6115
6209
|
}
|
|
@@ -6206,8 +6300,6 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6206
6300
|
const diskOffset = getDiskOffset(zipWriter.writer);
|
|
6207
6301
|
const diskNumber = getDiskNumber(zipWriter.writer);
|
|
6208
6302
|
options = Object.assign({}, options, attributesInfo.resolvedOptions, metadataInfo.resolvedOptions, sizesInfo.resolvedOptions, {
|
|
6209
|
-
internalFileAttribute: metadataInfo.resolvedOptions.internalFileAttributes,
|
|
6210
|
-
externalFileAttribute: attributesInfo.resolvedOptions.externalFileAttributes,
|
|
6211
6303
|
signature: options[PROPERTY_NAME_SIGNATURE],
|
|
6212
6304
|
crc32: options.crc32 === UNDEFINED_VALUE ? options[PROPERTY_NAME_SIGNATURE] : options.crc32,
|
|
6213
6305
|
offset: zipWriter.offset - diskOffset,
|
|
@@ -6221,14 +6313,20 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
6221
6313
|
zipWriter.files.delete(name);
|
|
6222
6314
|
throw error;
|
|
6223
6315
|
}
|
|
6224
|
-
Object.assign(fileEntry, {
|
|
6316
|
+
Object.assign(fileEntry, {
|
|
6317
|
+
name,
|
|
6318
|
+
comment,
|
|
6319
|
+
extraField,
|
|
6320
|
+
[PROPERTY_NAME_DEPRECATED_INTERNAL_FILE_ATTRIBUTES]: fileEntry.internalFileAttributes,
|
|
6321
|
+
[PROPERTY_NAME_DEPRECATED_EXTERNAL_FILE_ATTRIBUTES]: fileEntry.externalFileAttributes
|
|
6322
|
+
});
|
|
6225
6323
|
return new Entry(fileEntry);
|
|
6226
6324
|
}
|
|
6227
6325
|
|
|
6228
6326
|
function resolveAttributes(zipWriter, name, options) {
|
|
6229
6327
|
name = name.trim();
|
|
6230
6328
|
let msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
6231
|
-
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ?
|
|
6329
|
+
let versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? VERSION_MADE_BY_MSDOS : VERSION_MADE_BY_UNIX);
|
|
6232
6330
|
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
6233
6331
|
const uid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_UID);
|
|
6234
6332
|
const gid = getNumberOptionValue(zipWriter, options, PROPERTY_NAME_GID);
|
|
@@ -6262,7 +6360,7 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6262
6360
|
const hasMsDosProvided = msdosAttributesRaw !== UNDEFINED_VALUE || msdosAttributes !== UNDEFINED_VALUE;
|
|
6263
6361
|
if (hasUnixMetadata) {
|
|
6264
6362
|
msDosCompatible = false;
|
|
6265
|
-
versionMadeBy = (versionMadeBy &
|
|
6363
|
+
versionMadeBy = (versionMadeBy & MAX_8_BITS) | VERSION_MADE_BY_UNIX;
|
|
6266
6364
|
} else if (hasMsDosProvided) {
|
|
6267
6365
|
msDosCompatible = true;
|
|
6268
6366
|
versionMadeBy = (versionMadeBy & MAX_8_BITS);
|
|
@@ -6302,11 +6400,10 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6302
6400
|
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
6303
6401
|
}
|
|
6304
6402
|
}
|
|
6305
|
-
let unixExternalUpper;
|
|
6306
6403
|
if (!msDosCompatible) {
|
|
6307
6404
|
const unixModeProvided = unixMode !== UNDEFINED_VALUE || Boolean(setuid || setgid || sticky);
|
|
6308
|
-
|
|
6309
|
-
unixMode = unixMode === UNDEFINED_VALUE ?
|
|
6405
|
+
const defaultUnixMode = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6406
|
+
unixMode = unixMode === UNDEFINED_VALUE ? defaultUnixMode : (unixMode & MAX_16_BITS);
|
|
6310
6407
|
if (setuid) {
|
|
6311
6408
|
unixMode |= FILE_ATTR_UNIX_SETUID_MASK;
|
|
6312
6409
|
} else {
|
|
@@ -6335,17 +6432,20 @@ function resolveAttributes(zipWriter, name, options) {
|
|
|
6335
6432
|
if (hasMsDosProvided) {
|
|
6336
6433
|
externalFileAttributes = (externalFileAttributes & MAX_32_BITS) | (msdosAttributesRaw & MAX_8_BITS);
|
|
6337
6434
|
}
|
|
6435
|
+
const unixExternalUpper = (externalFileAttributes >> 16) & MAX_16_BITS;
|
|
6436
|
+
const symlink = unixMode !== UNDEFINED_VALUE && ((unixMode & FILE_ATTR_UNIX_TYPE_MASK) == FILE_ATTR_UNIX_TYPE_SYMLINK);
|
|
6338
6437
|
return {
|
|
6339
6438
|
name,
|
|
6340
6439
|
resolvedOptions: {
|
|
6341
6440
|
versionMadeBy,
|
|
6342
|
-
msDosCompatible,
|
|
6441
|
+
msDosCompatible: Boolean(msDosCompatible),
|
|
6343
6442
|
externalFileAttributes,
|
|
6344
6443
|
unixExternalUpper,
|
|
6345
6444
|
uid,
|
|
6346
6445
|
gid,
|
|
6347
6446
|
unixMode,
|
|
6348
6447
|
unixExtraFieldType,
|
|
6448
|
+
symlink,
|
|
6349
6449
|
setuid,
|
|
6350
6450
|
setgid,
|
|
6351
6451
|
sticky,
|
|
@@ -6787,6 +6887,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6787
6887
|
uid,
|
|
6788
6888
|
gid,
|
|
6789
6889
|
unixMode,
|
|
6890
|
+
symlink,
|
|
6790
6891
|
setuid,
|
|
6791
6892
|
setgid,
|
|
6792
6893
|
sticky,
|
|
@@ -6823,6 +6924,7 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6823
6924
|
uid,
|
|
6824
6925
|
gid,
|
|
6825
6926
|
unixMode,
|
|
6927
|
+
symlink: Boolean(symlink),
|
|
6826
6928
|
setuid,
|
|
6827
6929
|
setgid,
|
|
6828
6930
|
sticky,
|
|
@@ -6903,8 +7005,8 @@ async function createFileEntry(reader, writer, { diskNumberStart, lock }, entryI
|
|
|
6903
7005
|
rawLastModDate,
|
|
6904
7006
|
creationDate,
|
|
6905
7007
|
lastAccessDate,
|
|
6906
|
-
encrypted,
|
|
6907
|
-
zipCrypto,
|
|
7008
|
+
encrypted: Boolean(encrypted),
|
|
7009
|
+
zipCrypto: Boolean(zipCrypto),
|
|
6908
7010
|
size: metadataSize + compressedSize,
|
|
6909
7011
|
compressionMethod,
|
|
6910
7012
|
version,
|
|
@@ -8613,4 +8715,4 @@ function terminateWorkersAndModule() {
|
|
|
8613
8715
|
|
|
8614
8716
|
configureExternalAssets();
|
|
8615
8717
|
|
|
8616
|
-
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|
|
8718
|
+
export { BlobReader, BlobWriter, Data64URIReader, Data64URIWriter, ERR_AMBIGUOUS_ARCHIVE, ERR_BAD_FORMAT, ERR_CENTRAL_DIRECTORY_NOT_FOUND, ERR_DUPLICATED_NAME, ERR_ENCRYPTED, ERR_ENCRYPTED_CENTRAL_DIRECTORY, ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND, ERR_EOCDR_NOT_FOUND, ERR_EXTRAFIELD_ZIP64_NOT_FOUND, ERR_HTTP_RANGE, ERR_HTTP_RESOURCE_CHANGED, ERR_INVALID_AUTHENTICATION_CODE, ERR_INVALID_CODEC_DEFINITION, ERR_INVALID_CODEC_MODULE, ERR_INVALID_COMMENT, ERR_INVALID_COMMENT_TYPE, ERR_INVALID_COMPRESSED_DATA, ERR_INVALID_CRC32, ERR_INVALID_ENCRYPTION_STRENGTH, ERR_INVALID_ENTRY_COMMENT, ERR_INVALID_ENTRY_NAME, ERR_INVALID_EXTRAFIELD_DATA, ERR_INVALID_EXTRAFIELD_TYPE, ERR_INVALID_FILENAME_VALIDATION, ERR_INVALID_GID, ERR_INVALID_LEVEL, ERR_INVALID_MAX_APPENDED_DATA_SIZE, ERR_INVALID_MSDOS_ATTRIBUTES, ERR_INVALID_MSDOS_DATA, ERR_INVALID_PASSWORD, ERR_INVALID_PASSWORD_TYPE, ERR_INVALID_SIGNATURE, ERR_INVALID_SIGNATURE_DATA, ERR_INVALID_STRICTNESS, ERR_INVALID_UID, ERR_INVALID_UNCOMPRESSED_SIZE, ERR_INVALID_UNIX_EXTRA_FIELD_TYPE, ERR_INVALID_UNIX_ID_SIZE, ERR_INVALID_UNIX_MODE, ERR_INVALID_VERSION, ERR_ITERATOR_COMPLETED_TOO_SOON, ERR_LOCAL_FILE_HEADER_NOT_FOUND, ERR_OVERLAPPING_ENTRY, ERR_RESERVED_COMPRESSION_METHOD, ERR_SPLIT_ZIP_FILE, ERR_UNDEFINED_READER, ERR_UNDEFINED_UNCOMPRESSED_SIZE, ERR_UNDETERMINED_SIZE, ERR_UNSAFE_FILENAME, ERR_UNSUPPORTED_COMPRESSION$1 as ERR_UNSUPPORTED_COMPRESSION, ERR_UNSUPPORTED_CONTEXT, ERR_UNSUPPORTED_CRYPTO_API, ERR_UNSUPPORTED_ENCRYPTION, ERR_UNSUPPORTED_ENCRYPTION_PASS_THROUGH, ERR_UNSUPPORTED_ENCRYPTION_USDZ, ERR_UNSUPPORTED_FORMAT, ERR_WORKER_STARTUP_TIMEOUT, ERR_WRITER_NOT_INITIALIZED, ERR_ZIP_NOT_EMPTY, HttpRangeReader, HttpReader, Reader, SplitDataReader, SplitDataWriter, TextReader, TextWriter, Uint8ArrayReader, Uint8ArrayWriter, Writer, ZipReader, ZipReaderStream, ZipWriter, ZipWriterStream, configure, createBlobTempStream, createOPFSTempStream, createSyncAccessHandleTempStream, getMimeType, registerCodec, resetConfiguration, terminateWorkersAndModule as terminateWorkers, unregisterCodec };
|