@poppinss/multiparty 2.0.1 → 3.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/README.md +1 -1
- package/index.js +17 -4
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -271,5 +271,5 @@ stream uploads to disk for you.
|
|
|
271
271
|
|
|
272
272
|
[npm-version-image]: https://img.shields.io/npm/v/@poppinss/multiparty?style=for-the-badge
|
|
273
273
|
|
|
274
|
-
[gh-workflow-image]: https://img.shields.io/github/workflow/status/poppinss/multiparty/test?style=for-the-badge
|
|
274
|
+
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/poppinss/multiparty/test.yml?style=for-the-badge
|
|
275
275
|
[gh-workflow-url]: https://github.com/poppinss/multiparty/actions/workflows/test.yml "Github action"
|
package/index.js
CHANGED
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
'use strict'
|
|
10
10
|
|
|
11
11
|
var createError = require('http-errors')
|
|
12
|
-
var uid = require('uid-safe')
|
|
13
12
|
var stream = require('stream');
|
|
14
13
|
var util = require('util');
|
|
15
14
|
var fs = require('fs');
|
|
16
15
|
var path = require('path');
|
|
17
16
|
var os = require('os');
|
|
18
|
-
var
|
|
17
|
+
var crypto = require('crypto');
|
|
19
18
|
var StringDecoder = require('string_decoder').StringDecoder;
|
|
20
19
|
|
|
21
20
|
var START = 0;
|
|
@@ -48,6 +47,20 @@ var NAME_PARAM_RE = /\bname=(?:"([^"]+)"|([!#$%&'*+.0-9A-Z^_`a-z|~-]+))/i
|
|
|
48
47
|
|
|
49
48
|
exports.Form = Form;
|
|
50
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Generates a URL safe random string of a given size
|
|
52
|
+
*/
|
|
53
|
+
function randomUid(size) {
|
|
54
|
+
var bits = (size + 1) * 6
|
|
55
|
+
var buffer = crypto.randomBytes(Math.ceil(bits / 8))
|
|
56
|
+
return Buffer.from(buffer)
|
|
57
|
+
.toString('base64')
|
|
58
|
+
.replace(/\+/g, '-')
|
|
59
|
+
.replace(/\//g, '_')
|
|
60
|
+
.replace(/=/g, '')
|
|
61
|
+
.slice(0, size)
|
|
62
|
+
}
|
|
63
|
+
|
|
51
64
|
util.inherits(Form, stream.Writable);
|
|
52
65
|
function Form(options) {
|
|
53
66
|
var opts = options || {}
|
|
@@ -819,7 +832,7 @@ function setUpParser(self, boundary) {
|
|
|
819
832
|
|
|
820
833
|
function uploadPath(baseDir, filename) {
|
|
821
834
|
var ext = path.extname(filename).replace(FILE_EXT_RE, '$1');
|
|
822
|
-
var name =
|
|
835
|
+
var name = randomUid(18) + ext
|
|
823
836
|
return path.join(baseDir, name);
|
|
824
837
|
}
|
|
825
838
|
|
|
@@ -836,7 +849,7 @@ function parseFilename(headerValue) {
|
|
|
836
849
|
|
|
837
850
|
var filename = m[1] || m[2] || '';
|
|
838
851
|
filename = filename.replace(/%22|\\"/g, '"');
|
|
839
|
-
filename = filename.replace(/&#([
|
|
852
|
+
filename = filename.replace(/&#([0-9]{1,5});/g, function(m, code) {
|
|
840
853
|
return String.fromCharCode(code);
|
|
841
854
|
});
|
|
842
855
|
return filename.substr(filename.lastIndexOf('\\') + 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/multiparty",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "multipart/form-data parser which supports streaming",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"s3"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"http-errors": "^2.0.0"
|
|
20
|
-
"safe-buffer": "5.2.1",
|
|
21
|
-
"uid-safe": "2.1.5"
|
|
19
|
+
"http-errors": "^2.0.0"
|
|
22
20
|
},
|
|
23
21
|
"devDependencies": {
|
|
24
22
|
"eslint": "^8.9.0",
|