@zip.js/zip.js 2.6.10 → 2.6.13

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.
Files changed (71) hide show
  1. package/cli-deno/mc-zip.js +1 -1
  2. package/dist/zip-fs-full.js +21 -8
  3. package/dist/zip-fs-full.min.js +1 -1
  4. package/dist/zip-fs.js +21 -8
  5. package/dist/zip-fs.min.js +1 -1
  6. package/dist/zip-full.js +21 -8
  7. package/dist/zip-full.min.js +1 -1
  8. package/dist/zip-no-worker-deflate.min.js +1 -1
  9. package/dist/zip-no-worker-inflate.min.js +1 -1
  10. package/dist/zip-no-worker.min.js +1 -1
  11. package/dist/zip.js +21 -8
  12. package/dist/zip.min.js +1 -1
  13. package/index.d.ts +71 -3
  14. package/lib/core/util/cp437-decode.js +12 -5
  15. package/lib/core/zip-writer.js +9 -3
  16. package/package.json +15 -6
  17. package/tests/all/loader.html +2 -4
  18. package/tests/all/test-abort-signal-read.js +0 -1
  19. package/tests/all/test-abort-signal-write.js +0 -1
  20. package/tests/all/test-array.js +3 -1
  21. package/tests/all/test-base64.js +3 -1
  22. package/tests/all/test-blob.js +5 -1
  23. package/tests/all/test-codecs-interoperability.js +3 -1
  24. package/tests/all/test-crc.js +7 -12
  25. package/tests/all/test-crypto.js +3 -1
  26. package/tests/all/test-custom-io.js +3 -1
  27. package/tests/all/test-data-descriptor-signature.js +7 -1
  28. package/tests/all/test-data-descriptor.js +7 -1
  29. package/tests/all/test-duplicated-filename.js +24 -0
  30. package/tests/all/test-empty.js +3 -1
  31. package/tests/all/test-extended-timestamp.js +3 -1
  32. package/tests/all/test-extra-field.js +3 -2
  33. package/tests/all/test-fflate-no-worker.js +3 -1
  34. package/tests/all/test-fflate.js +3 -1
  35. package/tests/all/test-fs-base64.js +3 -1
  36. package/tests/all/test-fs-export-options.js +3 -1
  37. package/tests/all/test-fs-http-import.js +3 -1
  38. package/tests/all/test-fs-http-reader.js +3 -1
  39. package/tests/all/test-fs-replace.js +3 -1
  40. package/tests/all/test-fs-streams.js +3 -1
  41. package/tests/all/test-fs-text.js +3 -1
  42. package/tests/all/test-fs-unzip-store.js +3 -1
  43. package/tests/all/test-fs.js +3 -1
  44. package/tests/all/test-http-crypto.js +3 -2
  45. package/tests/all/test-http-range.js +3 -2
  46. package/tests/all/test-http-zip64.js +3 -2
  47. package/tests/all/test-invalid-crc.js +3 -1
  48. package/tests/all/test-no-worker.js +3 -1
  49. package/tests/all/test-pako-no-worker.js +3 -1
  50. package/tests/all/test-pako.js +3 -1
  51. package/tests/all/test-parallel-reads.js +3 -1
  52. package/tests/all/test-parallel-writes-auto-buffered.js +3 -1
  53. package/tests/all/test-parallel-writes-ordered.js +4 -2
  54. package/tests/all/test-parallel-writes.js +3 -1
  55. package/tests/all/test-readable-stream.js +8 -12
  56. package/tests/all/test-readable-zip-stream.js +3 -2
  57. package/tests/all/test-safe-closing.js +3 -1
  58. package/tests/all/test-store.js +9 -1
  59. package/tests/all/test-sw-worker.js +0 -1
  60. package/tests/all/test-sw.js +0 -1
  61. package/tests/all/test-worker-timeout.js +7 -12
  62. package/tests/all/test-wrapped.js +4 -2
  63. package/tests/all/test-writable-stream.js +23 -25
  64. package/tests/all/test-zip64-auto.js +3 -1
  65. package/tests/all/test-zip64-crypto.js +3 -1
  66. package/tests/all/test-zip64.js +3 -1
  67. package/tests/all/test-zipcrypto.js +3 -1
  68. package/tests/node-runner.js +17 -9
  69. package/tests/tests-data.js +1 -0
  70. package/build.sh +0 -3
  71. package/tests/run-tests.sh +0 -3
@@ -36,7 +36,7 @@ async function displayUsage() {
36
36
  await stdout.write(" --data-descriptor-signature add data descriptor signatures (default: false)\n");
37
37
  await stdout.write(" --keep-order keep entries order (default: true)\n");
38
38
  await stdout.write(" --zip64 use Zip64 format (default: false)\n");
39
- await stdout.write(" --prevent-parent-directories remove occurences of \"../\" in filenames\n");
39
+ await stdout.write(" --prevent-parent-directories remove occurences of \"../\" in filenames (default: true)\n");
40
40
  await stdout.write("\n");
41
41
  Deno.exit(-1);
42
42
  }
@@ -8080,14 +8080,21 @@
8080
8080
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8081
8081
  */
8082
8082
 
8083
+ /* global TextDecoder */
8084
+
8083
8085
  const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
8086
+ const VALID_CP437 = CP437.length == 256;
8084
8087
 
8085
- var decodeCP437 = stringValue => {
8086
- let result = "";
8087
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
8088
- result += CP437[stringValue[indexCharacter]];
8088
+ var decodeCP437 = (stringValue) => {
8089
+ if (VALID_CP437) {
8090
+ let result = "";
8091
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
8092
+ result += CP437[stringValue[indexCharacter]];
8093
+ }
8094
+ return result;
8095
+ } else {
8096
+ return new TextDecoder().decode(stringValue);
8089
8097
  }
8090
- return result;
8091
8098
  };
8092
8099
 
8093
8100
  /*
@@ -8767,6 +8774,7 @@
8767
8774
  options,
8768
8775
  config: getConfiguration(),
8769
8776
  files: new Map(),
8777
+ filenames: new Set(),
8770
8778
  offset: writer.size || 0,
8771
8779
  pendingCompressedSize: 0,
8772
8780
  pendingEntries: [],
@@ -8785,9 +8793,17 @@
8785
8793
  workers++;
8786
8794
  let promiseAddFile;
8787
8795
  try {
8796
+ name = name.trim();
8797
+ if (zipWriter.filenames.has(name)) {
8798
+ throw new Error(ERR_DUPLICATED_NAME);
8799
+ }
8800
+ zipWriter.filenames.add(name);
8788
8801
  promiseAddFile = addFile(zipWriter, name, reader, options);
8789
8802
  pendingAddFileCalls.add(promiseAddFile);
8790
8803
  return await promiseAddFile;
8804
+ } catch (error) {
8805
+ zipWriter.filenames.delete(name);
8806
+ throw error;
8791
8807
  } finally {
8792
8808
  pendingAddFileCalls.delete(promiseAddFile);
8793
8809
  workers--;
@@ -8824,9 +8840,6 @@
8824
8840
  } else {
8825
8841
  options.directory = name.endsWith(DIRECTORY_SIGNATURE);
8826
8842
  }
8827
- if (zipWriter.files.has(name)) {
8828
- throw new Error(ERR_DUPLICATED_NAME);
8829
- }
8830
8843
  const rawFilename = encodeText(name);
8831
8844
  if (rawFilename.length > MAX_16_BITS) {
8832
8845
  throw new Error(ERR_INVALID_ENTRY_NAME);