@zip.js/zip.js 2.18.1 → 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/index.cjs CHANGED
@@ -6030,19 +6030,11 @@ async function detectOverlappingEntry({
6030
6030
  const zip64 = Boolean(extraFieldZip64);
6031
6031
  const dataDescriptorArray = await readUint8Array(reader, dataOffset + compressedSize, DATA_DESCRIPTOR_RECORD_ZIP_64_LENGTH + DATA_DESCRIPTOR_RECORD_SIGNATURE_LENGTH);
6032
6032
  const dataDescriptorView = getDataView(dataDescriptorArray);
6033
- const ignoreCrc32 = fileEntry.encrypted && !fileEntry.zipCrypto;
6034
- let localDataDescriptor;
6035
- for (const [zip64Layout, signature] of [[zip64, true], [zip64, false], [!zip64, true], [!zip64, false]]) {
6036
- const candidate = readDataDescriptor(dataDescriptorView, zip64Layout, signature);
6037
- if (candidate && (ignoreCrc32 || candidate.crc32 == crc32) &&
6038
- candidate.compressedSize == compressedSize && candidate.uncompressedSize == uncompressedSize) {
6039
- localDataDescriptor = candidate;
6040
- break;
6041
- }
6042
- }
6043
- if (!localDataDescriptor) {
6044
- localDataDescriptor = readDataDescriptor(dataDescriptorView, zip64, false);
6045
- }
6033
+ const candidates = [[zip64, true], [zip64, false], [!zip64, true], [!zip64, false]]
6034
+ .map(([zip64Layout, signature]) => readDataDescriptor(dataDescriptorView, zip64Layout, signature))
6035
+ .filter(candidate => candidate && candidate.compressedSize == compressedSize && candidate.uncompressedSize == uncompressedSize);
6036
+ const localDataDescriptor = candidates.find(candidate => candidate.crc32 == crc32) || candidates[0] ||
6037
+ readDataDescriptor(dataDescriptorView, zip64, true) || readDataDescriptor(dataDescriptorView, zip64, false);
6046
6038
  if (localDataDescriptor) {
6047
6039
  fileEntry.localDirectory.dataDescriptor = localDataDescriptor;
6048
6040
  dataDescriptorLength = getDataDescriptorLength(localDataDescriptor.zip64, localDataDescriptor.signature);
@@ -9057,7 +9049,7 @@ function formatSupported(StreamClass, format) {
9057
9049
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9058
9050
  */
9059
9051
 
9060
- const VERSION = "2.18.1";
9052
+ const VERSION = "2.18.2";
9061
9053
 
9062
9054
  /*
9063
9055
  Copyright (c) 2025 Gildas Lormeau. All rights reserved.
package/index.d.cts CHANGED
@@ -2240,8 +2240,8 @@ export interface LocalDataDescriptor {
2240
2240
  * `true` if the record is preceded by its optional signature.
2241
2241
  *
2242
2242
  * The signature is not part of the original format, it is a later convention writers are free to follow. It is
2243
- * reported as absent when the values following it disagree with the central directory, since the record is then
2244
- * read as starting at the first byte.
2243
+ * `false` when the record is read as starting at its first byte, see {@link LocalDataDescriptor#zip64} for how the
2244
+ * layout is chosen.
2245
2245
  */
2246
2246
  signature: boolean;
2247
2247
  /**
@@ -2251,9 +2251,10 @@ export interface LocalDataDescriptor {
2251
2251
  * sizes, and the Zip64 extra field of the central directory record, written last, describes that record, not the
2252
2252
  * descriptor, so e.g. an entry placed past 4 GB can carry a Zip64 extra field in its central directory record for
2253
2253
  * its offset alone and a descriptor with 4-byte sizes. The record is therefore read with the layout, among the two
2254
- * widths with and without the signature, whose values agree with the central directory; when none does, the width
2255
- * announced by the Zip64 extra field of the local file header or of the central directory record is used, without
2256
- * the signature.
2254
+ * widths with and without the signature, whose sizes agree with the central directory, its CRC-32 too when the
2255
+ * central directory stores one and several layouts qualify; when none does, the width announced by the Zip64 extra
2256
+ * field of the local file header or of the central directory record is used, with the signature when the record
2257
+ * starts with one.
2257
2258
  */
2258
2259
  zip64: boolean;
2259
2260
  /**
package/index.d.ts CHANGED
@@ -2240,8 +2240,8 @@ export interface LocalDataDescriptor {
2240
2240
  * `true` if the record is preceded by its optional signature.
2241
2241
  *
2242
2242
  * The signature is not part of the original format, it is a later convention writers are free to follow. It is
2243
- * reported as absent when the values following it disagree with the central directory, since the record is then
2244
- * read as starting at the first byte.
2243
+ * `false` when the record is read as starting at its first byte, see {@link LocalDataDescriptor#zip64} for how the
2244
+ * layout is chosen.
2245
2245
  */
2246
2246
  signature: boolean;
2247
2247
  /**
@@ -2251,9 +2251,10 @@ export interface LocalDataDescriptor {
2251
2251
  * sizes, and the Zip64 extra field of the central directory record, written last, describes that record, not the
2252
2252
  * descriptor, so e.g. an entry placed past 4 GB can carry a Zip64 extra field in its central directory record for
2253
2253
  * its offset alone and a descriptor with 4-byte sizes. The record is therefore read with the layout, among the two
2254
- * widths with and without the signature, whose values agree with the central directory; when none does, the width
2255
- * announced by the Zip64 extra field of the local file header or of the central directory record is used, without
2256
- * the signature.
2254
+ * widths with and without the signature, whose sizes agree with the central directory, its CRC-32 too when the
2255
+ * central directory stores one and several layouts qualify; when none does, the width announced by the Zip64 extra
2256
+ * field of the local file header or of the central directory record is used, with the signature when the record
2257
+ * starts with one.
2257
2258
  */
2258
2259
  zip64: boolean;
2259
2260
  /**