@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 +7 -0
- package/README.md +2 -2
- package/index.js +6 -4
- package/package.json +9 -7
package/HISTORY.md
CHANGED
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 (
|
|
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
|
|
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 =
|
|
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": "
|
|
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": "
|
|
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": "^
|
|
21
|
-
"eslint-plugin-markdown": "
|
|
20
|
+
"eslint": "^8.5.0",
|
|
21
|
+
"eslint-plugin-markdown": "2.2.1",
|
|
22
22
|
"mkdirp": "^1.0.4",
|
|
23
|
-
"mocha": "^
|
|
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
|
|
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",
|