@zip.js/zip.js 2.7.63 → 2.7.64

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.
@@ -69,6 +69,8 @@ const VERSION_AES = 0x33;
69
69
 
70
70
  const DIRECTORY_SIGNATURE = "/";
71
71
 
72
+ const HEADER_SIZE = 26;
73
+
72
74
  const MAX_DATE = new Date(2107, 11, 31);
73
75
  const MIN_DATE = new Date(1980, 0, 1);
74
76
 
@@ -113,6 +115,7 @@ export {
113
115
  VERSION_DEFLATE,
114
116
  VERSION_ZIP64,
115
117
  VERSION_AES,
118
+ HEADER_SIZE,
116
119
  DIRECTORY_SIGNATURE,
117
120
  MIN_DATE,
118
121
  MAX_DATE,
package/lib/core/io.js CHANGED
@@ -513,6 +513,7 @@ class Uint8ArrayReader extends Reader {
513
513
 
514
514
  constructor(array) {
515
515
  super();
516
+ array = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
516
517
  Object.assign(this, {
517
518
  array,
518
519
  size: array.length
@@ -772,9 +772,8 @@ async function exportZip(zipWriter, entry, totalSize, options) {
772
772
  });
773
773
  }
774
774
  }
775
- await zipWriter.add(name, child.reader, Object.assign({
776
- directory: child.directory
777
- }, Object.assign({}, options, zipEntryOptions, childOptions, {
775
+ await zipWriter.add(name, child.reader, Object.assign({}, options, zipEntryOptions, childOptions, {
776
+ directory: child.directory,
778
777
  onprogress: async indexProgress => {
779
778
  if (options.onprogress) {
780
779
  entryOffsets.set(name, indexProgress);
@@ -786,7 +785,7 @@ async function exportZip(zipWriter, entry, totalSize, options) {
786
785
  }
787
786
  }
788
787
  }
789
- })));
788
+ }));
790
789
  await process(zipWriter, child);
791
790
  }
792
791
  }
@@ -61,6 +61,7 @@ import {
61
61
  FILE_ATTR_UNIX_TYPE_DIR,
62
62
  FILE_ATTR_UNIX_EXECUTABLE_MASK,
63
63
  DIRECTORY_SIGNATURE,
64
+ HEADER_SIZE,
64
65
  UNDEFINED_VALUE
65
66
  } from "./constants.js";
66
67
  import {
@@ -416,7 +417,8 @@ class ZipEntry {
416
417
  compressedSize
417
418
  } = zipEntry;
418
419
  const localDirectory = fileEntry.localDirectory = {};
419
- const dataArray = await readUint8Array(reader, offset, 30, diskNumberStart);
420
+ const dataArraySize = HEADER_SIZE + 4;
421
+ const dataArray = await readUint8Array(reader, offset, dataArraySize + 4, diskNumberStart);
420
422
  const dataView = getDataView(dataArray);
421
423
  let password = getOptionValue(zipEntry, options, "password");
422
424
  let rawPassword = getOptionValue(zipEntry, options, "rawPassword");
@@ -436,7 +438,7 @@ class ZipEntry {
436
438
  }
437
439
  readCommonHeader(localDirectory, dataView, 4);
438
440
  localDirectory.rawExtraField = localDirectory.extraFieldLength ?
439
- await readUint8Array(reader, offset + 30 + localDirectory.filenameLength, localDirectory.extraFieldLength, diskNumberStart) :
441
+ await readUint8Array(reader, offset + dataArraySize + localDirectory.filenameLength, localDirectory.extraFieldLength, diskNumberStart) :
440
442
  new Uint8Array();
441
443
  readCommonFooter(zipEntry, localDirectory, dataView, 4, true);
442
444
  Object.assign(fileEntry, {
@@ -455,7 +457,7 @@ class ZipEntry {
455
457
  throw new Error(ERR_ENCRYPTED);
456
458
  }
457
459
  }
458
- const dataOffset = offset + 30 + localDirectory.filenameLength + localDirectory.extraFieldLength;
460
+ const dataOffset = offset + dataArraySize + localDirectory.filenameLength + localDirectory.extraFieldLength;
459
461
  const size = compressedSize;
460
462
  const readable = reader.readable;
461
463
  Object.assign(readable, {