@zip.js/zip.js 2.18.0 → 2.18.2
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 +33 -33
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +33 -33
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +33 -33
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +33 -33
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +33 -33
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +33 -33
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +33 -33
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +33 -33
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +33 -33
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +33 -33
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +33 -33
- package/index-native.min.js +1 -1
- package/index.cjs +33 -33
- package/index.d.cts +15 -2
- package/index.d.ts +15 -2
- package/index.min.js +1 -1
- package/lib/core/version.js +1 -1
- package/lib/core/zip-reader.js +32 -32
- package/package.json +1 -1
package/lib/core/version.js
CHANGED
package/lib/core/zip-reader.js
CHANGED
|
@@ -1455,32 +1455,19 @@ async function detectOverlappingEntry({
|
|
|
1455
1455
|
}) {
|
|
1456
1456
|
let dataDescriptorLength = 0;
|
|
1457
1457
|
if (dataDescriptor) {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
} else {
|
|
1461
|
-
dataDescriptorLength = DATA_DESCRIPTOR_RECORD_LENGTH;
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
if (dataDescriptorLength) {
|
|
1465
|
-
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, dataDescriptorLength + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
1458
|
+
const zip64 = Boolean(extraFieldZip64);
|
|
1459
|
+
const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
|
|
1466
1460
|
const dataDescriptorView = getDataView(dataDescriptorArray);
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
signedDataDescriptor.compressedSize == compressedSize &&
|
|
1474
|
-
signedDataDescriptor.uncompressedSize == uncompressedSize) {
|
|
1475
|
-
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
1476
|
-
} else {
|
|
1477
|
-
signature = false;
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
if (dataDescriptorArray.length >= dataDescriptorLength) {
|
|
1481
|
-
const localDataDescriptor = readDataDescriptor(dataDescriptorView, signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0, extraFieldZip64);
|
|
1482
|
-
localDataDescriptor.signature = signature;
|
|
1461
|
+
const candidates = [[zip64, true], [zip64, false], [!zip64, true], [!zip64, false]]
|
|
1462
|
+
.map(([zip64Layout, signature]) => readDataDescriptor(dataDescriptorView, zip64Layout, signature))
|
|
1463
|
+
.filter(candidate => candidate && candidate.compressedSize == compressedSize && candidate.uncompressedSize == uncompressedSize);
|
|
1464
|
+
const localDataDescriptor = candidates.find(candidate => candidate.crc32 == crc32) || candidates[0] ||
|
|
1465
|
+
readDataDescriptor(dataDescriptorView, zip64, true) || readDataDescriptor(dataDescriptorView, zip64, false);
|
|
1466
|
+
if (localDataDescriptor) {
|
|
1483
1467
|
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
1468
|
+
dataDescriptorLength = getDataDescriptorLength(localDataDescriptor.zip64, localDataDescriptor.signature);
|
|
1469
|
+
} else {
|
|
1470
|
+
dataDescriptorLength = getDataDescriptorLength(zip64, false);
|
|
1484
1471
|
}
|
|
1485
1472
|
}
|
|
1486
1473
|
const range = {
|
|
@@ -1545,18 +1532,31 @@ function mergeRanges(sortedRanges, pendingRanges) {
|
|
|
1545
1532
|
return mergedRanges;
|
|
1546
1533
|
}
|
|
1547
1534
|
|
|
1548
|
-
function readDataDescriptor(dataDescriptorView,
|
|
1535
|
+
function readDataDescriptor(dataDescriptorView, zip64, signature) {
|
|
1536
|
+
const offset = signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0;
|
|
1537
|
+
if (dataDescriptorView.byteLength < getDataDescriptorLength(zip64, signature) ||
|
|
1538
|
+
(signature && getUint32(dataDescriptorView, 0) != DATA_DESCRIPTOR_RECORD_SIGNATURE)) {
|
|
1539
|
+
return UNDEFINED_VALUE;
|
|
1540
|
+
}
|
|
1549
1541
|
const crc32 = getUint32(dataDescriptorView, offset);
|
|
1550
1542
|
let compressedSize;
|
|
1551
1543
|
let uncompressedSize;
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1544
|
+
try {
|
|
1545
|
+
if (zip64) {
|
|
1546
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
1547
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
1548
|
+
} else {
|
|
1549
|
+
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
1550
|
+
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
1551
|
+
}
|
|
1552
|
+
} catch {
|
|
1553
|
+
return UNDEFINED_VALUE;
|
|
1558
1554
|
}
|
|
1559
|
-
return { crc32, compressedSize, uncompressedSize };
|
|
1555
|
+
return { signature, zip64, crc32, compressedSize, uncompressedSize };
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
function getDataDescriptorLength(zip64, signature) {
|
|
1559
|
+
return (zip64 ? DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH : DATA_DESCRIPTOR_RECORD_LENGTH) + (signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0);
|
|
1560
1560
|
}
|
|
1561
1561
|
|
|
1562
1562
|
function getDiskOffset(reader, diskNumber) {
|
package/package.json
CHANGED