@zip.js/zip.js 2.18.0 → 2.18.1
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 +39 -31
- package/dist/zip-core-external.min.js +1 -1
- package/dist/zip-core.js +39 -31
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core-external.js +39 -31
- package/dist/zip-fs-core-external.min.js +1 -1
- package/dist/zip-fs-core.js +39 -31
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-external.js +39 -31
- package/dist/zip-fs-external.min.js +1 -1
- package/dist/zip-fs-native.js +39 -31
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +39 -31
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +39 -31
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-native.js +39 -31
- package/dist/zip-native.min.js +1 -1
- package/dist/zip.js +39 -31
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +39 -31
- package/index-native.min.js +1 -1
- package/index.cjs +39 -31
- package/index.d.cts +12 -0
- package/index.d.ts +12 -0
- package/index.min.js +1 -1
- package/lib/core/version.js +1 -1
- package/lib/core/zip-reader.js +38 -30
- package/package.json +1 -1
package/lib/core/version.js
CHANGED
package/lib/core/zip-reader.js
CHANGED
|
@@ -1455,32 +1455,27 @@ 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
|
-
const
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
dataDescriptorLength += DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH;
|
|
1476
|
-
} else {
|
|
1477
|
-
signature = false;
|
|
1461
|
+
const ignoreCrc32 = fileEntry.encrypted && !fileEntry.zipCrypto;
|
|
1462
|
+
let localDataDescriptor;
|
|
1463
|
+
for (const [zip64Layout, signature] of [[zip64, true], [zip64, false], [!zip64, true], [!zip64, false]]) {
|
|
1464
|
+
const candidate = readDataDescriptor(dataDescriptorView, zip64Layout, signature);
|
|
1465
|
+
if (candidate && (ignoreCrc32 || candidate.crc32 == crc32) &&
|
|
1466
|
+
candidate.compressedSize == compressedSize && candidate.uncompressedSize == uncompressedSize) {
|
|
1467
|
+
localDataDescriptor = candidate;
|
|
1468
|
+
break;
|
|
1478
1469
|
}
|
|
1479
1470
|
}
|
|
1480
|
-
if (
|
|
1481
|
-
|
|
1482
|
-
|
|
1471
|
+
if (!localDataDescriptor) {
|
|
1472
|
+
localDataDescriptor = readDataDescriptor(dataDescriptorView, zip64, false);
|
|
1473
|
+
}
|
|
1474
|
+
if (localDataDescriptor) {
|
|
1483
1475
|
fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
|
|
1476
|
+
dataDescriptorLength = getDataDescriptorLength(localDataDescriptor.zip64, localDataDescriptor.signature);
|
|
1477
|
+
} else {
|
|
1478
|
+
dataDescriptorLength = getDataDescriptorLength(zip64, false);
|
|
1484
1479
|
}
|
|
1485
1480
|
}
|
|
1486
1481
|
const range = {
|
|
@@ -1545,18 +1540,31 @@ function mergeRanges(sortedRanges, pendingRanges) {
|
|
|
1545
1540
|
return mergedRanges;
|
|
1546
1541
|
}
|
|
1547
1542
|
|
|
1548
|
-
function readDataDescriptor(dataDescriptorView,
|
|
1543
|
+
function readDataDescriptor(dataDescriptorView, zip64, signature) {
|
|
1544
|
+
const offset = signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0;
|
|
1545
|
+
if (dataDescriptorView.byteLength < getDataDescriptorLength(zip64, signature) ||
|
|
1546
|
+
(signature && getUint32(dataDescriptorView, 0) != DATA_DESCRIPTOR_RECORD_SIGNATURE)) {
|
|
1547
|
+
return UNDEFINED_VALUE;
|
|
1548
|
+
}
|
|
1549
1549
|
const crc32 = getUint32(dataDescriptorView, offset);
|
|
1550
1550
|
let compressedSize;
|
|
1551
1551
|
let uncompressedSize;
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1552
|
+
try {
|
|
1553
|
+
if (zip64) {
|
|
1554
|
+
compressedSize = getBigUint64(dataDescriptorView, offset + 4);
|
|
1555
|
+
uncompressedSize = getBigUint64(dataDescriptorView, offset + 12);
|
|
1556
|
+
} else {
|
|
1557
|
+
compressedSize = getUint32(dataDescriptorView, offset + 4);
|
|
1558
|
+
uncompressedSize = getUint32(dataDescriptorView, offset + 8);
|
|
1559
|
+
}
|
|
1560
|
+
} catch {
|
|
1561
|
+
return UNDEFINED_VALUE;
|
|
1558
1562
|
}
|
|
1559
|
-
return { crc32, compressedSize, uncompressedSize };
|
|
1563
|
+
return { signature, zip64, crc32, compressedSize, uncompressedSize };
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
function getDataDescriptorLength(zip64, signature) {
|
|
1567
|
+
return (zip64 ? DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH : DATA_DESCRIPTOR_RECORD_LENGTH) + (signature ? DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH : 0);
|
|
1560
1568
|
}
|
|
1561
1569
|
|
|
1562
1570
|
function getDiskOffset(reader, diskNumber) {
|
package/package.json
CHANGED