🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

multer

Package Overview
Dependencies
Maintainers
5
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multer - npm Package Compare versions

Comparing version
2.1.1
to
2.2.0
+16
-1
lib/make-middleware.js

@@ -38,2 +38,3 @@ var is = require('type-is')

var uploadedFiles = []
var pendingFiles = []

@@ -86,3 +87,8 @@ function done (err) {

removeUploadedFiles(uploadedFiles, remove, function (err, storageErrors) {
var filesToRemove = uploadedFiles.concat(
pendingFiles.filter(function (f) { return f.path })
)
pendingFiles = []
removeUploadedFiles(filesToRemove, remove, function (err, storageErrors) {
if (err) return done(err)

@@ -152,2 +158,6 @@

if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNestingDepth')) {
if (fieldname.split('[').length - 1 > limits.fieldNestingDepth) return abortWithCode('LIMIT_FIELD_NESTING', fieldname)
}
appendField(req.body, fieldname, value)

@@ -217,3 +227,8 @@ })

pendingFiles.push(file)
storage._handleFile(req, file, function (err, info) {
var idx = pendingFiles.indexOf(file)
if (idx !== -1) pendingFiles.splice(idx, 1)
if (aborting) {

@@ -220,0 +235,0 @@ appender.removePlaceholder(placeholder)

+2
-1

@@ -11,3 +11,4 @@ var util = require('util')

LIMIT_UNEXPECTED_FILE: 'Unexpected field',
MISSING_FIELD_NAME: 'Field name missing'
MISSING_FIELD_NAME: 'Field name missing',
LIMIT_FIELD_NESTING: 'Field name nesting too deep'
}

@@ -14,0 +15,0 @@

{
"name": "multer",
"description": "Middleware for handling `multipart/form-data`.",
"version": "2.1.1",
"version": "2.2.0",
"contributors": [

@@ -6,0 +6,0 @@ "Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",

@@ -284,2 +284,3 @@ # Multer [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Test Coverage][test-image]][test-url] [![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]

`headerPairs` | For multipart forms, the max number of header key=>value pairs to parse | 2000
`fieldNestingDepth` | Max number of nesting levels for field names (e.g. `a[b][c]` has 2 levels) | Infinity

@@ -311,2 +312,11 @@ Specifying the limits can help protect your site against denial of service (DoS) attacks.

## Security
Specifying the [limits](#limits) can help protect your site against denial of service (DoS) attacks. The following limits are recommended for most applications:
- `fileSize` -- set to the maximum expected file size for your use case
- `files` -- set to the maximum number of files per request
- `fields` -- set to the maximum number of text fields per request
- `fieldNestingDepth` -- set to the minimum depth your field names require (e.g. `3` for `a[b][c]`)
## Error handling

@@ -313,0 +323,0 @@

@@ -37,4 +37,9 @@ var fs = require('fs')

var finalPath = path.join(destination, filename)
if (file.stream.destroyed) return
var outStream = fs.createWriteStream(finalPath)
file.path = finalPath
file.stream.pipe(outStream)

@@ -41,0 +46,0 @@ outStream.on('error', cb)