@poppinss/multiparty 1.0.2 → 2.0.0

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/HISTORY.md CHANGED
@@ -1,3 +1,10 @@
1
+ unreleased
2
+ ==========
3
+
4
+ * Fix handling of unquoted values in `Content-Disposition`
5
+ * deps: http-errors@~1.8.1
6
+ - deps: toidentifier@1.0.1
7
+
1
8
  4.2.2 / 2020-07-27
2
9
  ==================
3
10
 
package/README.md CHANGED
@@ -113,14 +113,14 @@ form.on('part', function(part) {
113
113
  // You *must* act on the part by reading it
114
114
  // NOTE: if you want to ignore it, just call "part.resume()"
115
115
 
116
- if (!part.filename) {
116
+ if (part.filename === undefined) {
117
117
  // filename is not defined when this is a field and not a file
118
118
  console.log('got field named ' + part.name);
119
119
  // ignore field's content
120
120
  part.resume();
121
121
  }
122
122
 
123
- if (part.filename) {
123
+ if (part.filename !== undefined) {
124
124
  // filename is defined when this is a file
125
125
  count++;
126
126
  console.log('got file named ' + part.name);
package/index.js CHANGED
@@ -42,7 +42,9 @@ var Z = 122;
42
42
  var CONTENT_TYPE_RE = /^multipart\/(?:form-data|related)(?:;|$)/i;
43
43
  var CONTENT_TYPE_PARAM_RE = /;\s*([^=]+)=(?:"([^"]+)"|([^;]+))/gi;
44
44
  var FILE_EXT_RE = /(\.[_\-a-zA-Z0-9]{0,16})[\S\s]*/;
45
+ var FILENAME_PARAM_RE = /\bfilename=(?:"(.*?)"|([!#$%&'*+.0-9A-Z^_`a-z|~-]+))($|; )/i
45
46
  var LAST_BOUNDARY_SUFFIX_LEN = 4; // --\r\n
47
+ var NAME_PARAM_RE = /\bname=(?:"([^"]+)"|([!#$%&'*+.0-9A-Z^_`a-z|~-]+))/i
46
48
 
47
49
  exports.Form = Form;
48
50
 
@@ -458,8 +460,8 @@ Form.prototype.onParseHeaderEnd = function() {
458
460
 
459
461
  var m;
460
462
  if (this.headerField === 'content-disposition') {
461
- if (m = this.headerValue.match(/\bname="([^"]+)"/i)) {
462
- this.partName = m[1];
463
+ if (m = NAME_PARAM_RE.exec(this.headerValue)) {
464
+ this.partName = m[1] || m[2] || ''
463
465
  }
464
466
  this.partFilename = parseFilename(this.headerValue);
465
467
  } else if (this.headerField === 'content-transfer-encoding') {
@@ -795,7 +797,7 @@ function uploadPath(baseDir, filename) {
795
797
  }
796
798
 
797
799
  function parseFilename(headerValue) {
798
- var m = headerValue.match(/\bfilename="(.*?)"($|; )/i);
800
+ var m = FILENAME_PARAM_RE.exec(headerValue)
799
801
  if (!m) {
800
802
  m = headerValue.match(/\bfilename\*=utf-8''(.*?)($|; )/i)
801
803
  if (m) {
@@ -805,7 +807,7 @@ function parseFilename(headerValue) {
805
807
  }
806
808
  }
807
809
 
808
- var filename = m[1];
810
+ var filename = m[1] || m[2] || '';
809
811
  filename = filename.replace(/%22|\\"/g, '"');
810
812
  filename = filename.replace(/&#([\d]{4});/g, function(m, code) {
811
813
  return String.fromCharCode(code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poppinss/multiparty",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "description": "multipart/form-data parser which supports streaming",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -12,15 +12,15 @@
12
12
  "s3"
13
13
  ],
14
14
  "dependencies": {
15
- "http-errors": "~1.8.0",
15
+ "http-errors": "^2.0.0",
16
16
  "safe-buffer": "5.2.1",
17
17
  "uid-safe": "2.1.5"
18
18
  },
19
19
  "devDependencies": {
20
- "eslint": "^7.27.0",
21
- "eslint-plugin-markdown": "^2.2.0",
20
+ "eslint": "^8.5.0",
21
+ "eslint-plugin-markdown": "2.2.1",
22
22
  "mkdirp": "^1.0.4",
23
- "mocha": "^8.4.0",
23
+ "mocha": "^9.1.3",
24
24
  "nyc": "15.1.0",
25
25
  "pend": "1.2.0",
26
26
  "require-all": "3.0.0",
@@ -34,8 +34,10 @@
34
34
  "index.js"
35
35
  ],
36
36
  "scripts": {
37
- "lint": "eslint --plugin markdown --ext js,md .",
38
- "test": "mocha --reporter spec --bail --check-leaks test/"
37
+ "lint": "eslint .",
38
+ "test": "mocha --reporter spec --bail --check-leaks test/",
39
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
40
+ "test-cov": "nyc --reporter=html --reporter=text npm test"
39
41
  },
40
42
  "directories": {
41
43
  "example": "examples",