Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multer

Package Overview
Dependencies
Maintainers
3
Versions
46
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.0.0-rc.1 to 2.0.0-rc.2

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change log

## 2.0.0-rc.2 - 2020-03-15
- Allow limits to be passed as string, e.g. `'12MB'`
- Remove `parts` limit in favour of `fields` & `files`
- Set reasonable defaults for all limits
## 2.0.0-rc.1 - 2020-02-26

@@ -8,0 +14,0 @@

31

index.js
const createFileFilter = require('./lib/file-filter')
const createMiddleware = require('./lib/middleware')
const bytes = require('bytes')
const kLimits = Symbol('limits')
function parseLimit (limits, key, defaultValue) {
const input = limits[key] == null ? defaultValue : limits[key]
const value = bytes.parse(input)
if (!Number.isFinite(value)) throw new Error(`Invalid limit "${key}" given: ${limits[key]}`)
if (!Number.isInteger(value)) throw new Error(`Invalid limit "${key}" given: ${value}`)
return value
}
function _middleware (limits, fields, fileStrategy) {

@@ -15,19 +27,26 @@ return createMiddleware(() => ({

constructor (options) {
this.limits = options.limits
this[kLimits] = {
fieldNameSize: parseLimit(options.limits || {}, 'fieldNameSize', '100B'),
fieldSize: parseLimit(options.limits || {}, 'fieldSize', '8KB'),
fields: parseLimit(options.limits || {}, 'fields', 1000),
fileSize: parseLimit(options.limits || {}, 'fileSize', '8MB'),
files: parseLimit(options.limits || {}, 'files', 10),
headerPairs: parseLimit(options.limits || {}, 'headerPairs', 2000)
}
}
single (name) {
return _middleware(this.limits, [{ name: name, maxCount: 1 }], 'VALUE')
return _middleware(this[kLimits], [{ name: name, maxCount: 1 }], 'VALUE')
}
array (name, maxCount) {
return _middleware(this.limits, [{ name: name, maxCount: maxCount }], 'ARRAY')
return _middleware(this[kLimits], [{ name: name, maxCount: maxCount }], 'ARRAY')
}
fields (fields) {
return _middleware(this.limits, fields, 'OBJECT')
return _middleware(this[kLimits], fields, 'OBJECT')
}
none () {
return _middleware(this.limits, [], 'NONE')
return _middleware(this[kLimits], [], 'NONE')
}

@@ -38,3 +57,3 @@

fields: [],
limits: this.limits,
limits: this[kLimits],
fileFilter: () => {},

@@ -41,0 +60,0 @@ fileStrategy: 'ARRAY'

1

lib/error.js
const errorMessages = new Map([
['CLIENT_ABORTED', 'Client aborted'],
['LIMIT_PART_COUNT', 'Too many parts'],
['LIMIT_FILE_SIZE', 'File too large'],

@@ -5,0 +4,0 @@ ['LIMIT_FILE_COUNT', 'Too many files'],

@@ -105,3 +105,2 @@ const path = require('path')

req.on('aborted', () => reject(new MulterError('CLIENT_ABORTED')))
busboy.on('partsLimit', () => reject(new MulterError('LIMIT_PART_COUNT')))
busboy.on('filesLimit', () => reject(new MulterError('LIMIT_FILE_COUNT')))

@@ -108,0 +107,0 @@ busboy.on('fieldsLimit', () => reject(new MulterError('LIMIT_FIELD_COUNT')))

{
"name": "multer",
"description": "Middleware for handling `multipart/form-data`.",
"version": "2.0.0-rc.1",
"version": "2.0.0-rc.2",
"contributors": [

@@ -24,2 +24,3 @@ "Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",

"busboy": "^0.3.1",
"bytes": "^3.1.0",
"fs-temp": "^1.1.1",

@@ -42,3 +43,3 @@ "has-own-property": "^1.0.0",

"recursive-nullify": "^1.0.0",
"standard": "^14.3.1",
"standard": "^14.3.3",
"testdata-w3c-json-form": "^1.0.0"

@@ -45,0 +46,0 @@ },

@@ -136,14 +136,15 @@ # Multer [![Build Status](https://travis-ci.org/expressjs/multer.svg?branch=master)](https://travis-ci.org/expressjs/multer) [![NPM version](https://badge.fury.io/js/multer.svg)](https://badge.fury.io/js/multer) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

The following integer values are available:
The following limits are available:
Key | Description | Default
--- | --- | ---
`fieldNameSize` | Max field name size | 100 bytes
`fieldSize` | Max field value size | 1MB
`fields` | Max number of non-file fields | Infinity
`fileSize` | For multipart forms, the max file size (in bytes) | Infinity
`files` | For multipart forms, the max number of file fields | Infinity
`parts` | For multipart forms, the max number of parts (fields + files) | Infinity
`headerPairs` | For multipart forms, the max number of header key=>value pairs to parse | 2000
`fieldNameSize` | Max field name size | `'100B'`
`fieldSize` | Max field value size | `'8KB'`
`fields` | Max number of non-file fields | `1000`
`fileSize` | The max file size | `'8MB'`
`files` | The max number of file fields | `10`
`headerPairs` | The max number of header key=>value pairs to parse | `2000` (same as Node's http)
Bytes limits can be passed either as a number, or as a string with an appropriate prefix.
Specifying the limits can help protect your site against denial of service (DoS) attacks.

@@ -150,0 +151,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc