@tryghost/zip 1.1.40 → 1.1.42

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 (2) hide show
  1. package/lib/extract.js +17 -9
  2. package/package.json +6 -6
package/lib/extract.js CHANGED
@@ -12,7 +12,15 @@ function throwOnSymlinks(entry) {
12
12
 
13
13
  if (symlink) {
14
14
  throw new errors.UnsupportedMediaTypeError({
15
- message: 'Symlinks in ZIP-files are not allowed'
15
+ message: 'Symlinks are not allowed in the zip folder.'
16
+ });
17
+ }
18
+ }
19
+
20
+ function throwOnLargeFilenames(entry) {
21
+ if (Buffer.byteLength(entry.fileName, 'utf8') >= 254) {
22
+ throw new errors.UnsupportedMediaTypeError({
23
+ message: 'File names in the zip folder must be shorter than 254 characters.'
16
24
  });
17
25
  }
18
26
  }
@@ -36,14 +44,14 @@ module.exports = (zipToExtract, destination, options) => {
36
44
 
37
45
  opts.dir = destination;
38
46
 
39
- if (opts.onEntry) {
40
- opts.onEntry = (entry, zipfile) => {
41
- throwOnSymlinks(entry);
42
- options.onEntry(entry, zipfile);
43
- };
44
- } else {
45
- opts.onEntry = throwOnSymlinks;
46
- }
47
+ const originalOnEntry = opts.onEntry;
48
+ opts.onEntry = (entry, zipfile) => {
49
+ throwOnSymlinks(entry);
50
+ throwOnLargeFilenames(entry);
51
+ if (originalOnEntry) {
52
+ originalOnEntry(entry, zipfile);
53
+ }
54
+ };
47
55
 
48
56
  return extract(zipToExtract, opts).then(() => {
49
57
  return {path: destination};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/zip",
3
- "version": "1.1.40",
3
+ "version": "1.1.42",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/zip",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -19,17 +19,17 @@
19
19
  "access": "public"
20
20
  },
21
21
  "devDependencies": {
22
- "c8": "8.0.1",
22
+ "c8": "9.1.0",
23
23
  "folder-hash": "4.0.4",
24
- "fs-extra": "11.1.1",
25
- "mocha": "10.2.0",
24
+ "fs-extra": "11.2.0",
25
+ "mocha": "10.4.0",
26
26
  "should": "13.2.3",
27
27
  "sinon": "17.0.1"
28
28
  },
29
29
  "dependencies": {
30
- "@tryghost/errors": "^1.3.0",
30
+ "@tryghost/errors": "^1.3.2",
31
31
  "archiver": "^5.0.0",
32
32
  "extract-zip": "^2.0.1"
33
33
  },
34
- "gitHead": "2a91c8a1f54eef339c90e381252a1c8bbb7aeee4"
34
+ "gitHead": "77c5215535f391c2a10fcf275a16bfc79f70109d"
35
35
  }