@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
package/dist/zip-full.js CHANGED
@@ -7079,14 +7079,21 @@
7079
7079
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7080
7080
  */
7081
7081
 
7082
+ /* global TextDecoder */
7083
+
7082
7084
  const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
7085
+ const VALID_CP437 = CP437.length == 256;
7083
7086
 
7084
- var decodeCP437 = stringValue => {
7085
- let result = "";
7086
- for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
7087
- result += CP437[stringValue[indexCharacter]];
7087
+ var decodeCP437 = (stringValue) => {
7088
+ if (VALID_CP437) {
7089
+ let result = "";
7090
+ for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
7091
+ result += CP437[stringValue[indexCharacter]];
7092
+ }
7093
+ return result;
7094
+ } else {
7095
+ return new TextDecoder().decode(stringValue);
7088
7096
  }
7089
- return result;
7090
7097
  };
7091
7098
 
7092
7099
  /*
@@ -7766,6 +7773,7 @@
7766
7773
  options,
7767
7774
  config: getConfiguration(),
7768
7775
  files: new Map(),
7776
+ filenames: new Set(),
7769
7777
  offset: writer.size || 0,
7770
7778
  pendingCompressedSize: 0,
7771
7779
  pendingEntries: [],
@@ -7784,9 +7792,17 @@
7784
7792
  workers++;
7785
7793
  let promiseAddFile;
7786
7794
  try {
7795
+ name = name.trim();
7796
+ if (zipWriter.filenames.has(name)) {
7797
+ throw new Error(ERR_DUPLICATED_NAME);
7798
+ }
7799
+ zipWriter.filenames.add(name);
7787
7800
  promiseAddFile = addFile(zipWriter, name, reader, options);
7788
7801
  pendingAddFileCalls.add(promiseAddFile);
7789
7802
  return await promiseAddFile;
7803
+ } catch (error) {
7804
+ zipWriter.filenames.delete(name);
7805
+ throw error;
7790
7806
  } finally {
7791
7807
  pendingAddFileCalls.delete(promiseAddFile);
7792
7808
  workers--;
@@ -7823,9 +7839,6 @@
7823
7839
  } else {
7824
7840
  options.directory = name.endsWith(DIRECTORY_SIGNATURE);
7825
7841
  }
7826
- if (zipWriter.files.has(name)) {
7827
- throw new Error(ERR_DUPLICATED_NAME);
7828
- }
7829
7842
  const rawFilename = encodeText(name);
7830
7843
  if (rawFilename.length > MAX_16_BITS) {
7831
7844
  throw new Error(ERR_INVALID_ENTRY_NAME);