@zip.js/zip.js 2.7.55 → 2.7.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-fs-full.js +121 -69
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +121 -61
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +113 -64
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +113 -56
- package/dist/zip.min.js +1 -1
- package/index.cjs +121 -69
- package/index.d.ts +7 -1
- package/index.min.js +1 -1
- package/lib/core/constants.js +2 -0
- package/lib/core/zip-entry.js +5 -1
- package/lib/core/zip-writer.js +38 -17
- package/package.json +1 -1
package/dist/zip-full.js
CHANGED
|
@@ -1246,7 +1246,6 @@
|
|
|
1246
1246
|
}
|
|
1247
1247
|
|
|
1248
1248
|
// Copy as much as possible from input to output:
|
|
1249
|
-
// eslint-disable-next-line no-constant-condition
|
|
1250
1249
|
while (true) {
|
|
1251
1250
|
// Fill the win as much as possible:
|
|
1252
1251
|
if (lookahead <= 1) {
|
|
@@ -1341,7 +1340,6 @@
|
|
|
1341
1340
|
|
|
1342
1341
|
// We check for insufficient lookahead only every 8th comparison;
|
|
1343
1342
|
// the 256th check will be made at strstart+258.
|
|
1344
|
-
// eslint-disable-next-line no-empty
|
|
1345
1343
|
do {
|
|
1346
1344
|
// empty block
|
|
1347
1345
|
} while (win[++scan] == win[++match] && win[++scan] == win[++match] && win[++scan] == win[++match]
|
|
@@ -1377,7 +1375,6 @@
|
|
|
1377
1375
|
let hash_head = 0; // head of the hash chain
|
|
1378
1376
|
let bflush; // set if current block must be flushed
|
|
1379
1377
|
|
|
1380
|
-
// eslint-disable-next-line no-constant-condition
|
|
1381
1378
|
while (true) {
|
|
1382
1379
|
// Make sure that we always have enough lookahead, except
|
|
1383
1380
|
// at the end of the input file. We need MAX_MATCH bytes
|
|
@@ -1484,7 +1481,6 @@
|
|
|
1484
1481
|
let max_insert;
|
|
1485
1482
|
|
|
1486
1483
|
// Process the input block.
|
|
1487
|
-
// eslint-disable-next-line no-constant-condition
|
|
1488
1484
|
while (true) {
|
|
1489
1485
|
// Make sure that we always have enough lookahead, except
|
|
1490
1486
|
// at the end of the input file. We need MAX_MATCH bytes
|
|
@@ -2834,7 +2830,6 @@
|
|
|
2834
2830
|
m = q < s.read ? s.read - q - 1 : s.end - q;
|
|
2835
2831
|
|
|
2836
2832
|
// process input and output based on current state
|
|
2837
|
-
// eslint-disable-next-line no-constant-condition
|
|
2838
2833
|
while (true) {
|
|
2839
2834
|
switch (mode) {
|
|
2840
2835
|
// waiting for "i:"=input, "o:"=output, "x:"=nothing
|
|
@@ -3325,7 +3320,6 @@
|
|
|
3325
3320
|
|
|
3326
3321
|
// process input based on current state
|
|
3327
3322
|
// DEBUG dtree
|
|
3328
|
-
// eslint-disable-next-line no-constant-condition
|
|
3329
3323
|
while (true) {
|
|
3330
3324
|
let bl, bd, tl, td, bl_, bd_, tl_, td_;
|
|
3331
3325
|
switch (mode) {
|
|
@@ -3602,7 +3596,6 @@
|
|
|
3602
3596
|
mode = DTREE;
|
|
3603
3597
|
/* falls through */
|
|
3604
3598
|
case DTREE:
|
|
3605
|
-
// eslint-disable-next-line no-constant-condition
|
|
3606
3599
|
while (true) {
|
|
3607
3600
|
t = table;
|
|
3608
3601
|
if (index >= 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) {
|
|
@@ -3910,7 +3903,6 @@
|
|
|
3910
3903
|
const istate = z.istate;
|
|
3911
3904
|
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
|
|
3912
3905
|
r = Z_BUF_ERROR;
|
|
3913
|
-
// eslint-disable-next-line no-constant-condition
|
|
3914
3906
|
while (true) {
|
|
3915
3907
|
switch (istate.mode) {
|
|
3916
3908
|
case METHOD:
|
|
@@ -4290,6 +4282,9 @@
|
|
|
4290
4282
|
const BITFLAG_DATA_DESCRIPTOR = 0x0008;
|
|
4291
4283
|
const BITFLAG_LANG_ENCODING_FLAG = 0x0800;
|
|
4292
4284
|
const FILE_ATTR_MSDOS_DIR_MASK = 0x10;
|
|
4285
|
+
const FILE_ATTR_UNIX_DIR_MASK = 0x4000;
|
|
4286
|
+
const FILE_ATTR_UNIX_EXECUTABLE_MASK = 0o111;
|
|
4287
|
+
const FILE_ATTR_UNIX_DEFAULT_MASK = 0o644;
|
|
4293
4288
|
|
|
4294
4289
|
const VERSION_DEFLATE = 0x14;
|
|
4295
4290
|
const VERSION_ZIP64 = 0x2D;
|
|
@@ -4390,7 +4385,8 @@
|
|
|
4390
4385
|
if (typeof navigator != UNDEFINED_TYPE && navigator.hardwareConcurrency) {
|
|
4391
4386
|
maxWorkers = navigator.hardwareConcurrency;
|
|
4392
4387
|
}
|
|
4393
|
-
|
|
4388
|
+
// eslint-disable-next-line no-unused-vars
|
|
4389
|
+
} catch (_) {
|
|
4394
4390
|
// ignored
|
|
4395
4391
|
}
|
|
4396
4392
|
const DEFAULT_CONFIGURATION = {
|
|
@@ -5828,7 +5824,8 @@
|
|
|
5828
5824
|
if (IMPORT_KEY_SUPPORTED) {
|
|
5829
5825
|
try {
|
|
5830
5826
|
return await subtle.importKey(format, password, algorithm, extractable, keyUsages);
|
|
5831
|
-
|
|
5827
|
+
// eslint-disable-next-line no-unused-vars
|
|
5828
|
+
} catch (_) {
|
|
5832
5829
|
IMPORT_KEY_SUPPORTED = false;
|
|
5833
5830
|
return misc.importKey(password);
|
|
5834
5831
|
}
|
|
@@ -5841,7 +5838,8 @@
|
|
|
5841
5838
|
if (DERIVE_BITS_SUPPORTED) {
|
|
5842
5839
|
try {
|
|
5843
5840
|
return await subtle.deriveBits(algorithm, baseKey, length);
|
|
5844
|
-
|
|
5841
|
+
// eslint-disable-next-line no-unused-vars
|
|
5842
|
+
} catch (_) {
|
|
5845
5843
|
DERIVE_BITS_SUPPORTED = false;
|
|
5846
5844
|
return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
|
|
5847
5845
|
}
|
|
@@ -6159,11 +6157,13 @@
|
|
|
6159
6157
|
try {
|
|
6160
6158
|
const CompressionStream = useCompressionStream && CodecStreamNative ? CodecStreamNative : CodecStream;
|
|
6161
6159
|
readable = pipeThrough(readable, new CompressionStream(COMPRESSION_FORMAT, options));
|
|
6162
|
-
|
|
6160
|
+
// eslint-disable-next-line no-unused-vars
|
|
6161
|
+
} catch (_) {
|
|
6163
6162
|
if (useCompressionStream) {
|
|
6164
6163
|
try {
|
|
6165
6164
|
readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
|
|
6166
|
-
|
|
6165
|
+
// eslint-disable-next-line no-unused-vars
|
|
6166
|
+
} catch (_) {
|
|
6167
6167
|
return readable;
|
|
6168
6168
|
}
|
|
6169
6169
|
} else {
|
|
@@ -6406,7 +6406,8 @@
|
|
|
6406
6406
|
async function callHandler(handler, ...parameters) {
|
|
6407
6407
|
try {
|
|
6408
6408
|
await handler(...parameters);
|
|
6409
|
-
|
|
6409
|
+
// eslint-disable-next-line no-unused-vars
|
|
6410
|
+
} catch (_) {
|
|
6410
6411
|
// ignored
|
|
6411
6412
|
}
|
|
6412
6413
|
}
|
|
@@ -6423,7 +6424,8 @@
|
|
|
6423
6424
|
let worker;
|
|
6424
6425
|
try {
|
|
6425
6426
|
worker = getWebWorker(workerData.scripts[0], baseURL, workerData);
|
|
6426
|
-
|
|
6427
|
+
// eslint-disable-next-line no-unused-vars
|
|
6428
|
+
} catch (_) {
|
|
6427
6429
|
WEB_WORKERS_SUPPORTED = false;
|
|
6428
6430
|
return createWorkerInterface(workerData, config);
|
|
6429
6431
|
}
|
|
@@ -6526,13 +6528,15 @@
|
|
|
6526
6528
|
}
|
|
6527
6529
|
try {
|
|
6528
6530
|
scriptUrl = new URL(url, baseURL);
|
|
6529
|
-
|
|
6531
|
+
// eslint-disable-next-line no-unused-vars
|
|
6532
|
+
} catch (_) {
|
|
6530
6533
|
scriptUrl = url;
|
|
6531
6534
|
}
|
|
6532
6535
|
if (classicWorkersSupported) {
|
|
6533
6536
|
try {
|
|
6534
6537
|
worker = new Worker(scriptUrl);
|
|
6535
|
-
|
|
6538
|
+
// eslint-disable-next-line no-unused-vars
|
|
6539
|
+
} catch (_) {
|
|
6536
6540
|
classicWorkersSupported = false;
|
|
6537
6541
|
worker = new Worker(scriptUrl, workerOptions);
|
|
6538
6542
|
}
|
|
@@ -6570,7 +6574,8 @@
|
|
|
6570
6574
|
try {
|
|
6571
6575
|
worker.postMessage(message, transferables);
|
|
6572
6576
|
return true;
|
|
6573
|
-
|
|
6577
|
+
// eslint-disable-next-line no-unused-vars
|
|
6578
|
+
} catch (_) {
|
|
6574
6579
|
transferStreamsSupported = false;
|
|
6575
6580
|
message.readable = message.writable = null;
|
|
6576
6581
|
worker.postMessage(message);
|
|
@@ -6713,7 +6718,8 @@
|
|
|
6713
6718
|
pool = pool.filter(data => data != workerData);
|
|
6714
6719
|
try {
|
|
6715
6720
|
await workerData.terminate();
|
|
6716
|
-
|
|
6721
|
+
// eslint-disable-next-line no-unused-vars
|
|
6722
|
+
} catch (_) {
|
|
6717
6723
|
// ignored
|
|
6718
6724
|
}
|
|
6719
6725
|
}, terminateWorkerTimeout);
|
|
@@ -7054,7 +7060,7 @@
|
|
|
7054
7060
|
combineSizeEocd
|
|
7055
7061
|
} = httpReader;
|
|
7056
7062
|
if (isHttpFamily(url) && (useRangeHeader || forceRangeRequests) && (typeof preventHeadRequest == "undefined" || preventHeadRequest)) {
|
|
7057
|
-
const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -
|
|
7063
|
+
const response = await sendRequest(HTTP_METHOD_GET, httpReader, getRangeHeaders(httpReader, combineSizeEocd ? -22 : undefined));
|
|
7058
7064
|
if (!forceRangeRequests && response.headers.get(HTTP_HEADER_ACCEPT_RANGES) != HTTP_RANGE_UNIT) {
|
|
7059
7065
|
throw new Error(ERR_HTTP_RANGE);
|
|
7060
7066
|
} else {
|
|
@@ -7577,22 +7583,23 @@
|
|
|
7577
7583
|
const PROPERTY_NAME_CREATION_DATE = "creationDate";
|
|
7578
7584
|
const PROPERTY_NAME_RAW_CREATION_DATE = "rawCreationDate";
|
|
7579
7585
|
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE = "internalFileAttribute";
|
|
7586
|
+
const PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES = "internalFileAttributes";
|
|
7580
7587
|
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE = "externalFileAttribute";
|
|
7588
|
+
const PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES = "externalFileAttributes";
|
|
7581
7589
|
const PROPERTY_NAME_MS_DOS_COMPATIBLE = "msDosCompatible";
|
|
7582
7590
|
const PROPERTY_NAME_ZIP64 = "zip64";
|
|
7583
7591
|
const PROPERTY_NAME_ENCRYPTED = "encrypted";
|
|
7584
7592
|
const PROPERTY_NAME_VERSION = "version";
|
|
7585
7593
|
const PROPERTY_NAME_VERSION_MADE_BY = "versionMadeBy";
|
|
7586
7594
|
const PROPERTY_NAME_ZIPCRYPTO = "zipCrypto";
|
|
7595
|
+
const PROPERTY_NAME_DIRECTORY = "directory";
|
|
7596
|
+
const PROPERTY_NAME_EXECUTABLE = "executable";
|
|
7587
7597
|
|
|
7588
7598
|
const PROPERTY_NAMES = [
|
|
7589
7599
|
PROPERTY_NAME_FILENAME, PROPERTY_NAME_RAW_FILENAME, PROPERTY_NAME_COMPPRESSED_SIZE, PROPERTY_NAME_UNCOMPPRESSED_SIZE,
|
|
7590
7600
|
PROPERTY_NAME_LAST_MODIFICATION_DATE, PROPERTY_NAME_RAW_LAST_MODIFICATION_DATE, PROPERTY_NAME_COMMENT, PROPERTY_NAME_RAW_COMMENT,
|
|
7591
7601
|
PROPERTY_NAME_LAST_ACCESS_DATE, PROPERTY_NAME_CREATION_DATE, PROPERTY_NAME_OFFSET, PROPERTY_NAME_DISK_NUMBER_START,
|
|
7592
|
-
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE,
|
|
7593
|
-
PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY,
|
|
7594
|
-
PROPERTY_NAME_ZIPCRYPTO, "directory", "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField",
|
|
7595
|
-
"extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
|
|
7602
|
+
PROPERTY_NAME_DISK_NUMBER_START, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, PROPERTY_NAME_MS_DOS_COMPATIBLE, PROPERTY_NAME_ZIP64, PROPERTY_NAME_ENCRYPTED, PROPERTY_NAME_VERSION, PROPERTY_NAME_VERSION_MADE_BY, PROPERTY_NAME_ZIPCRYPTO, PROPERTY_NAME_DIRECTORY, PROPERTY_NAME_EXECUTABLE, "bitFlag", "signature", "filenameUTF8", "commentUTF8", "compressionMethod", "extraField", "rawExtraField", "extraFieldZip64", "extraFieldUnicodePath", "extraFieldUnicodeComment", "extraFieldAES", "extraFieldNTFS", "extraFieldExtendedTimestamp"];
|
|
7596
7603
|
|
|
7597
7604
|
class Entry {
|
|
7598
7605
|
|
|
@@ -7783,14 +7790,20 @@
|
|
|
7783
7790
|
const extraFieldOffset = filenameOffset + fileEntry.filenameLength;
|
|
7784
7791
|
const commentOffset = extraFieldOffset + fileEntry.extraFieldLength;
|
|
7785
7792
|
const versionMadeBy = getUint16(directoryView, offset + 4);
|
|
7786
|
-
const msDosCompatible =
|
|
7793
|
+
const msDosCompatible = versionMadeBy >> 8 == 0;
|
|
7794
|
+
const unixCompatible = versionMadeBy >> 8 == 3;
|
|
7787
7795
|
const rawFilename = directoryArray.subarray(filenameOffset, extraFieldOffset);
|
|
7788
7796
|
const commentLength = getUint16(directoryView, offset + 32);
|
|
7789
7797
|
const endOffset = commentOffset + commentLength;
|
|
7790
7798
|
const rawComment = directoryArray.subarray(commentOffset, endOffset);
|
|
7791
7799
|
const filenameUTF8 = languageEncodingFlag;
|
|
7792
7800
|
const commentUTF8 = languageEncodingFlag;
|
|
7793
|
-
const
|
|
7801
|
+
const externalFileAttributes = getUint32(directoryView, offset + 38);
|
|
7802
|
+
const directory =
|
|
7803
|
+
(msDosCompatible && ((getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK)) ||
|
|
7804
|
+
(unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_DIR_MASK) == FILE_ATTR_UNIX_DIR_MASK)) ||
|
|
7805
|
+
(rawFilename.length && rawFilename[rawFilename.length - 1] == DIRECTORY_SIGNATURE.charCodeAt(0));
|
|
7806
|
+
const executable = (unixCompatible && (((externalFileAttributes >> 16) & FILE_ATTR_UNIX_EXECUTABLE_MASK) == FILE_ATTR_UNIX_EXECUTABLE_MASK));
|
|
7794
7807
|
const offsetFileEntry = getUint32(directoryView, offset + 42) + prependedDataLength;
|
|
7795
7808
|
Object.assign(fileEntry, {
|
|
7796
7809
|
versionMadeBy,
|
|
@@ -7801,13 +7814,16 @@
|
|
|
7801
7814
|
directory,
|
|
7802
7815
|
offset: offsetFileEntry,
|
|
7803
7816
|
diskNumberStart: getUint16(directoryView, offset + 34),
|
|
7804
|
-
|
|
7805
|
-
|
|
7817
|
+
internalFileAttributes: getUint16(directoryView, offset + 36),
|
|
7818
|
+
externalFileAttributes,
|
|
7806
7819
|
rawFilename,
|
|
7807
7820
|
filenameUTF8,
|
|
7808
7821
|
commentUTF8,
|
|
7809
|
-
rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
|
|
7822
|
+
rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset),
|
|
7823
|
+
executable
|
|
7810
7824
|
});
|
|
7825
|
+
fileEntry.internalFileAttribute = fileEntry.internalFileAttributes;
|
|
7826
|
+
fileEntry.externalFileAttribute = fileEntry.externalFileAttributes;
|
|
7811
7827
|
const decode = getOptionValue$1(zipReader, options, "decodeText") || decodeText;
|
|
7812
7828
|
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
7813
7829
|
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
@@ -7835,7 +7851,8 @@
|
|
|
7835
7851
|
if (onprogress) {
|
|
7836
7852
|
try {
|
|
7837
7853
|
await onprogress(indexFile + 1, filesLength, new Entry(fileEntry));
|
|
7838
|
-
|
|
7854
|
+
// eslint-disable-next-line no-unused-vars
|
|
7855
|
+
} catch (_) {
|
|
7839
7856
|
// ignored
|
|
7840
7857
|
}
|
|
7841
7858
|
}
|
|
@@ -8047,7 +8064,8 @@
|
|
|
8047
8064
|
});
|
|
8048
8065
|
offsetExtraField += 4 + size;
|
|
8049
8066
|
}
|
|
8050
|
-
|
|
8067
|
+
// eslint-disable-next-line no-unused-vars
|
|
8068
|
+
} catch (_) {
|
|
8051
8069
|
// ignored
|
|
8052
8070
|
}
|
|
8053
8071
|
const compressionMethod = getUint16(dataView, offset + 4);
|
|
@@ -8154,7 +8172,8 @@
|
|
|
8154
8172
|
}
|
|
8155
8173
|
offsetExtraField += 4 + attributeSize;
|
|
8156
8174
|
}
|
|
8157
|
-
|
|
8175
|
+
// eslint-disable-next-line no-unused-vars
|
|
8176
|
+
} catch (_) {
|
|
8158
8177
|
// ignored
|
|
8159
8178
|
}
|
|
8160
8179
|
try {
|
|
@@ -8175,7 +8194,8 @@
|
|
|
8175
8194
|
Object.assign(extraFieldNTFS, extraFieldData);
|
|
8176
8195
|
Object.assign(directory, extraFieldData);
|
|
8177
8196
|
}
|
|
8178
|
-
|
|
8197
|
+
// eslint-disable-next-line no-unused-vars
|
|
8198
|
+
} catch (_) {
|
|
8179
8199
|
// ignored
|
|
8180
8200
|
}
|
|
8181
8201
|
}
|
|
@@ -8244,7 +8264,8 @@
|
|
|
8244
8264
|
const date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
|
|
8245
8265
|
try {
|
|
8246
8266
|
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5, (time & 0x001F) * 2, 0);
|
|
8247
|
-
|
|
8267
|
+
// eslint-disable-next-line no-unused-vars
|
|
8268
|
+
} catch (_) {
|
|
8248
8269
|
// ignored
|
|
8249
8270
|
}
|
|
8250
8271
|
}
|
|
@@ -8423,10 +8444,37 @@
|
|
|
8423
8444
|
|
|
8424
8445
|
async function addFile(zipWriter, name, reader, options) {
|
|
8425
8446
|
name = name.trim();
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8447
|
+
const msDosCompatible = getOptionValue(zipWriter, options, PROPERTY_NAME_MS_DOS_COMPATIBLE);
|
|
8448
|
+
const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, msDosCompatible ? 20 : 768);
|
|
8449
|
+
const executable = getOptionValue(zipWriter, options, PROPERTY_NAME_EXECUTABLE);
|
|
8450
|
+
if (versionMadeBy > MAX_16_BITS) {
|
|
8451
|
+
throw new Error(ERR_INVALID_VERSION);
|
|
8452
|
+
}
|
|
8453
|
+
let externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTES, 0);
|
|
8454
|
+
if (externalFileAttributes === 0) {
|
|
8455
|
+
externalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_EXTERNAL_FILE_ATTRIBUTE, 0);
|
|
8456
|
+
}
|
|
8457
|
+
if (!options.directory && name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
8458
|
+
options.directory = true;
|
|
8459
|
+
}
|
|
8460
|
+
const directory = getOptionValue(zipWriter, options, PROPERTY_NAME_DIRECTORY);
|
|
8461
|
+
if (directory) {
|
|
8462
|
+
if (!name.endsWith(DIRECTORY_SIGNATURE)) {
|
|
8463
|
+
name += DIRECTORY_SIGNATURE;
|
|
8464
|
+
}
|
|
8465
|
+
if (externalFileAttributes === 0) {
|
|
8466
|
+
if (msDosCompatible) {
|
|
8467
|
+
externalFileAttributes = FILE_ATTR_MSDOS_DIR_MASK;
|
|
8468
|
+
} else {
|
|
8469
|
+
externalFileAttributes = FILE_ATTR_UNIX_DIR_MASK << 16;
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
} else if (!msDosCompatible && externalFileAttributes === 0) {
|
|
8473
|
+
if (executable) {
|
|
8474
|
+
externalFileAttributes = (FILE_ATTR_UNIX_EXECUTABLE_MASK | FILE_ATTR_UNIX_DEFAULT_MASK) << 16;
|
|
8475
|
+
} else {
|
|
8476
|
+
externalFileAttributes = FILE_ATTR_UNIX_DEFAULT_MASK << 16;
|
|
8477
|
+
}
|
|
8430
8478
|
}
|
|
8431
8479
|
const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
|
|
8432
8480
|
let rawFilename = encode(name);
|
|
@@ -8448,16 +8496,13 @@
|
|
|
8448
8496
|
if (version > MAX_16_BITS) {
|
|
8449
8497
|
throw new Error(ERR_INVALID_VERSION);
|
|
8450
8498
|
}
|
|
8451
|
-
const versionMadeBy = getOptionValue(zipWriter, options, PROPERTY_NAME_VERSION_MADE_BY, 20);
|
|
8452
|
-
if (versionMadeBy > MAX_16_BITS) {
|
|
8453
|
-
throw new Error(ERR_INVALID_VERSION);
|
|
8454
|
-
}
|
|
8455
8499
|
const lastModDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_MODIFICATION_DATE, new Date());
|
|
8456
8500
|
const lastAccessDate = getOptionValue(zipWriter, options, PROPERTY_NAME_LAST_ACCESS_DATE);
|
|
8457
8501
|
const creationDate = getOptionValue(zipWriter, options, PROPERTY_NAME_CREATION_DATE);
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8502
|
+
let internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTES, 0);
|
|
8503
|
+
if (internalFileAttributes === 0) {
|
|
8504
|
+
internalFileAttributes = getOptionValue(zipWriter, options, PROPERTY_NAME_INTERNAL_FILE_ATTRIBUTE, 0);
|
|
8505
|
+
}
|
|
8461
8506
|
const passThrough = getOptionValue(zipWriter, options, "passThrough");
|
|
8462
8507
|
let password, rawPassword;
|
|
8463
8508
|
if (!passThrough) {
|
|
@@ -8573,8 +8618,10 @@
|
|
|
8573
8618
|
dataDescriptorSignature,
|
|
8574
8619
|
signal,
|
|
8575
8620
|
msDosCompatible,
|
|
8576
|
-
internalFileAttribute,
|
|
8577
|
-
|
|
8621
|
+
internalFileAttribute: internalFileAttributes,
|
|
8622
|
+
internalFileAttributes,
|
|
8623
|
+
externalFileAttribute: externalFileAttributes,
|
|
8624
|
+
externalFileAttributes,
|
|
8578
8625
|
useCompressionStream,
|
|
8579
8626
|
passThrough,
|
|
8580
8627
|
encrypted: Boolean((password && getLength(password)) || (rawPassword && getLength(rawPassword))) || (passThrough && encrypted),
|
|
@@ -8695,7 +8742,8 @@
|
|
|
8695
8742
|
if (error) {
|
|
8696
8743
|
try {
|
|
8697
8744
|
error.corruptedEntry = true;
|
|
8698
|
-
|
|
8745
|
+
// eslint-disable-next-line no-unused-vars
|
|
8746
|
+
} catch (_) {
|
|
8699
8747
|
// ignored
|
|
8700
8748
|
}
|
|
8701
8749
|
}
|
|
@@ -8777,6 +8825,7 @@
|
|
|
8777
8825
|
zipCrypto,
|
|
8778
8826
|
dataDescriptor,
|
|
8779
8827
|
directory,
|
|
8828
|
+
executable,
|
|
8780
8829
|
versionMadeBy,
|
|
8781
8830
|
rawComment,
|
|
8782
8831
|
rawExtraField,
|
|
@@ -8788,8 +8837,8 @@
|
|
|
8788
8837
|
encryptionStrength,
|
|
8789
8838
|
extendedTimestamp,
|
|
8790
8839
|
msDosCompatible,
|
|
8791
|
-
|
|
8792
|
-
|
|
8840
|
+
internalFileAttributes,
|
|
8841
|
+
externalFileAttributes,
|
|
8793
8842
|
useCompressionStream,
|
|
8794
8843
|
passThrough
|
|
8795
8844
|
} = options;
|
|
@@ -8798,6 +8847,7 @@
|
|
|
8798
8847
|
versionMadeBy,
|
|
8799
8848
|
zip64,
|
|
8800
8849
|
directory: Boolean(directory),
|
|
8850
|
+
executable: Boolean(executable),
|
|
8801
8851
|
filenameUTF8: true,
|
|
8802
8852
|
rawFilename,
|
|
8803
8853
|
commentUTF8: true,
|
|
@@ -8808,8 +8858,8 @@
|
|
|
8808
8858
|
rawExtraField,
|
|
8809
8859
|
extendedTimestamp,
|
|
8810
8860
|
msDosCompatible,
|
|
8811
|
-
|
|
8812
|
-
|
|
8861
|
+
internalFileAttributes,
|
|
8862
|
+
externalFileAttributes,
|
|
8813
8863
|
diskNumberStart
|
|
8814
8864
|
};
|
|
8815
8865
|
let {
|
|
@@ -8969,7 +9019,8 @@
|
|
|
8969
9019
|
setBigUint64(extraFieldNTFSView, 12, lastModTimeNTFS);
|
|
8970
9020
|
setBigUint64(extraFieldNTFSView, 20, getTimeNTFS(lastAccessDate) || lastModTimeNTFS);
|
|
8971
9021
|
setBigUint64(extraFieldNTFSView, 28, getTimeNTFS(creationDate) || lastModTimeNTFS);
|
|
8972
|
-
|
|
9022
|
+
// eslint-disable-next-line no-unused-vars
|
|
9023
|
+
} catch (_) {
|
|
8973
9024
|
rawExtraFieldNTFS = new Uint8Array();
|
|
8974
9025
|
}
|
|
8975
9026
|
} else {
|
|
@@ -9257,15 +9308,13 @@
|
|
|
9257
9308
|
rawComment,
|
|
9258
9309
|
versionMadeBy,
|
|
9259
9310
|
headerArray,
|
|
9260
|
-
directory,
|
|
9261
9311
|
zip64,
|
|
9262
9312
|
zip64UncompressedSize,
|
|
9263
9313
|
zip64CompressedSize,
|
|
9264
9314
|
zip64DiskNumberStart,
|
|
9265
9315
|
zip64Offset,
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
externalFileAttribute,
|
|
9316
|
+
internalFileAttributes,
|
|
9317
|
+
externalFileAttributes,
|
|
9269
9318
|
diskNumberStart,
|
|
9270
9319
|
uncompressedSize,
|
|
9271
9320
|
compressedSize
|
|
@@ -9284,11 +9333,9 @@
|
|
|
9284
9333
|
setUint16(directoryView, offset + 30, extraFieldLength);
|
|
9285
9334
|
setUint16(directoryView, offset + 32, getLength(rawComment));
|
|
9286
9335
|
setUint16(directoryView, offset + 34, zip64 && zip64DiskNumberStart ? MAX_16_BITS : diskNumberStart);
|
|
9287
|
-
setUint16(directoryView, offset + 36,
|
|
9288
|
-
if (
|
|
9289
|
-
setUint32(directoryView, offset + 38,
|
|
9290
|
-
} else if (directory && msDosCompatible) {
|
|
9291
|
-
setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK);
|
|
9336
|
+
setUint16(directoryView, offset + 36, internalFileAttributes);
|
|
9337
|
+
if (externalFileAttributes) {
|
|
9338
|
+
setUint32(directoryView, offset + 38, externalFileAttributes);
|
|
9292
9339
|
}
|
|
9293
9340
|
setUint32(directoryView, offset + 42, zip64 && zip64Offset ? MAX_32_BITS : fileEntryOffset);
|
|
9294
9341
|
arraySet(directoryArray, rawFilename, offset + 46);
|
|
@@ -9308,7 +9355,8 @@
|
|
|
9308
9355
|
if (options.onprogress) {
|
|
9309
9356
|
try {
|
|
9310
9357
|
await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
|
|
9311
|
-
|
|
9358
|
+
// eslint-disable-next-line no-unused-vars
|
|
9359
|
+
} catch (_) {
|
|
9312
9360
|
// ignored
|
|
9313
9361
|
}
|
|
9314
9362
|
}
|
|
@@ -9463,7 +9511,8 @@
|
|
|
9463
9511
|
let baseURL;
|
|
9464
9512
|
try {
|
|
9465
9513
|
baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('zip-full.js', document.baseURI).href));
|
|
9466
|
-
|
|
9514
|
+
// eslint-disable-next-line no-unused-vars
|
|
9515
|
+
} catch (_) {
|
|
9467
9516
|
// ignored
|
|
9468
9517
|
}
|
|
9469
9518
|
e(configure);
|