@zip.js/zip.js 2.7.43 → 2.7.45
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 +52 -21
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +48 -19
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +47 -19
- 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 +45 -17
- package/dist/zip.min.js +1 -1
- package/index.cjs +52 -21
- package/index.d.ts +18 -12
- package/index.min.js +1 -1
- package/lib/core/zip-reader.js +10 -4
- package/lib/core/zip-writer.js +16 -10
- package/package.json +4 -7
package/lib/core/zip-reader.js
CHANGED
|
@@ -276,10 +276,16 @@ class ZipReader {
|
|
|
276
276
|
rawExtraField: directoryArray.subarray(extraFieldOffset, commentOffset)
|
|
277
277
|
});
|
|
278
278
|
const decode = getOptionValue(zipReader, options, "decodeText") || decodeText;
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
const rawFilenameEncoding = filenameUTF8 ? CHARSET_UTF8 : filenameEncoding || CHARSET_CP437;
|
|
280
|
+
const rawCommentEncoding = commentUTF8 ? CHARSET_UTF8 : commentEncoding || CHARSET_CP437;
|
|
281
|
+
let filename = decode(rawFilename, rawFilenameEncoding);
|
|
282
|
+
if (filename === UNDEFINED_VALUE) {
|
|
283
|
+
filename = decodeText(rawFilename, rawFilenameEncoding);
|
|
284
|
+
}
|
|
285
|
+
let comment = decode(rawComment, rawCommentEncoding);
|
|
286
|
+
if (comment === UNDEFINED_VALUE) {
|
|
287
|
+
comment = decodeText(rawComment, rawCommentEncoding);
|
|
288
|
+
}
|
|
283
289
|
Object.assign(fileEntry, {
|
|
284
290
|
rawComment,
|
|
285
291
|
filename,
|
package/lib/core/zip-writer.js
CHANGED
|
@@ -225,12 +225,18 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
225
225
|
options.directory = name.endsWith(DIRECTORY_SIGNATURE);
|
|
226
226
|
}
|
|
227
227
|
const encode = getOptionValue(zipWriter, options, "encodeText", encodeText);
|
|
228
|
-
|
|
228
|
+
let rawFilename = encode(name);
|
|
229
|
+
if (rawFilename === UNDEFINED_VALUE) {
|
|
230
|
+
rawFilename = encodeText(name);
|
|
231
|
+
}
|
|
229
232
|
if (getLength(rawFilename) > MAX_16_BITS) {
|
|
230
233
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
231
234
|
}
|
|
232
235
|
const comment = options.comment || "";
|
|
233
|
-
|
|
236
|
+
let rawComment = encode(comment);
|
|
237
|
+
if (rawComment === UNDEFINED_VALUE) {
|
|
238
|
+
rawComment = encodeText(comment);
|
|
239
|
+
}
|
|
234
240
|
if (getLength(rawComment) > MAX_16_BITS) {
|
|
235
241
|
throw new Error(ERR_INVALID_ENTRY_COMMENT);
|
|
236
242
|
}
|
|
@@ -296,7 +302,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
296
302
|
dataDescriptor = true;
|
|
297
303
|
if (zip64 || zip64 === UNDEFINED_VALUE) {
|
|
298
304
|
zip64 = true;
|
|
299
|
-
uncompressedSize = maximumCompressedSize = MAX_32_BITS;
|
|
305
|
+
uncompressedSize = maximumCompressedSize = MAX_32_BITS + 1;
|
|
300
306
|
}
|
|
301
307
|
} else {
|
|
302
308
|
uncompressedSize = reader.size;
|
|
@@ -304,11 +310,11 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
304
310
|
}
|
|
305
311
|
}
|
|
306
312
|
const { diskOffset, diskNumber, maxSize } = zipWriter.writer;
|
|
307
|
-
const zip64UncompressedSize = zip64Enabled || uncompressedSize
|
|
308
|
-
const zip64CompressedSize = zip64Enabled || maximumCompressedSize
|
|
309
|
-
const zip64Offset = zip64Enabled || zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset
|
|
313
|
+
const zip64UncompressedSize = zip64Enabled || uncompressedSize > MAX_32_BITS;
|
|
314
|
+
const zip64CompressedSize = zip64Enabled || maximumCompressedSize > MAX_32_BITS;
|
|
315
|
+
const zip64Offset = zip64Enabled || zipWriter.offset + zipWriter.pendingEntriesSize - diskOffset > MAX_32_BITS;
|
|
310
316
|
const supportZip64SplitFile = getOptionValue(zipWriter, options, "supportZip64SplitFile", true);
|
|
311
|
-
const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize)
|
|
317
|
+
const zip64DiskNumberStart = (supportZip64SplitFile && zip64Enabled) || diskNumber + Math.ceil(zipWriter.pendingEntriesSize / maxSize) > MAX_16_BITS;
|
|
312
318
|
if (zip64Offset || zip64UncompressedSize || zip64CompressedSize || zip64DiskNumberStart) {
|
|
313
319
|
if (zip64 === false || !keepOrder) {
|
|
314
320
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
@@ -333,7 +339,7 @@ async function addFile(zipWriter, name, reader, options) {
|
|
|
333
339
|
zip64DiskNumberStart,
|
|
334
340
|
password,
|
|
335
341
|
rawPassword,
|
|
336
|
-
level: !useCompressionStream && zipWriter.config.CompressionStream === UNDEFINED_VALUE ? 0 : level,
|
|
342
|
+
level: !useCompressionStream && (zipWriter.config.CompressionStream === UNDEFINED_VALUE && zipWriter.config.CompressionStreamNative === UNDEFINED_VALUE) ? 0 : level,
|
|
337
343
|
useWebWorkers,
|
|
338
344
|
encryptionStrength,
|
|
339
345
|
extendedTimestamp,
|
|
@@ -451,7 +457,7 @@ async function getFileEntry(zipWriter, name, reader, entryInfo, options) {
|
|
|
451
457
|
fileEntry.offset = zipWriter.offset - diskOffset;
|
|
452
458
|
if (fileEntry.zip64) {
|
|
453
459
|
setZip64ExtraInfo(fileEntry, options);
|
|
454
|
-
} else if (fileEntry.offset
|
|
460
|
+
} else if (fileEntry.offset > MAX_32_BITS) {
|
|
455
461
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
456
462
|
}
|
|
457
463
|
zipWriter.offset += fileEntry.size;
|
|
@@ -1068,7 +1074,7 @@ async function closeFile(zipWriter, comment, options) {
|
|
|
1068
1074
|
lastDiskNumber++;
|
|
1069
1075
|
}
|
|
1070
1076
|
let zip64 = getOptionValue(zipWriter, options, "zip64");
|
|
1071
|
-
if (directoryOffset
|
|
1077
|
+
if (directoryOffset > MAX_32_BITS || directoryDataLength > MAX_32_BITS || filesLength > MAX_16_BITS || lastDiskNumber > MAX_16_BITS) {
|
|
1072
1078
|
if (zip64 === false) {
|
|
1073
1079
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
1074
1080
|
} else {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A JavaScript library to zip and unzip files in the browser, Deno and Node.js",
|
|
4
4
|
"author": "Gildas Lormeau",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
|
-
"version": "2.7.
|
|
6
|
+
"version": "2.7.45",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"zip",
|
|
@@ -77,12 +77,9 @@
|
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
79
79
|
"@rollup/plugin-replace": "^5.0.5",
|
|
80
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
80
81
|
"http-server": "^14.1.1",
|
|
81
|
-
"rollup": "^
|
|
82
|
-
"
|
|
83
|
-
"typedoc": "^0.25.7"
|
|
84
|
-
},
|
|
85
|
-
"overrides": {
|
|
86
|
-
"terser": "^5.30.4"
|
|
82
|
+
"rollup": "^4.17.2",
|
|
83
|
+
"typedoc": "^0.25.13"
|
|
87
84
|
}
|
|
88
85
|
}
|