Socket
Socket
Sign inDemoInstall

formidable

Package Overview
Dependencies
5
Maintainers
5
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.1 to 3.2.3

4

package.json
{
"name": "formidable",
"version": "3.2.1",
"version": "3.2.3",
"license": "MIT",

@@ -48,2 +48,3 @@ "description": "A node.js module for parsing form data, especially file uploads.",

"express": "4.17.1",
"formdata-polyfill": "^4.0.10",
"husky": "4.2.5",

@@ -57,3 +58,2 @@ "jest": "27.2.4",

"prettier-plugin-pkgjson": "0.2.8",
"request": "2.88.2",
"supertest": "6.1.6"

@@ -60,0 +60,0 @@ },

@@ -309,3 +309,3 @@ <p align="center">

extensions of the original files or not
- `options.allowEmptyFiles` **{boolean}** - default `true`; allow upload empty
- `options.allowEmptyFiles` **{boolean}** - default `false`; allow upload empty
files

@@ -315,3 +315,3 @@ - `options.minFileSize` **{number}** - default `1` (1byte); the minium size of

- `options.maxFiles` **{number}** - default `Infinity`;
limit the amount of uploaded files.
limit the amount of uploaded files, set Infinity for unlimited
- `options.maxFileSize` **{number}** - default `200 * 1024 * 1024` (200mb);

@@ -321,3 +321,3 @@ limit the size of each uploaded file.

limit the size of the batch of uploaded files.
- `options.maxFields` **{number}** - default `1000`; limit the number of fields, set 0 for unlimited
- `options.maxFields` **{number}** - default `1000`; limit the number of fields, set Infinity for unlimited
- `options.maxFieldsSize` **{number}** - default `20 * 1024 * 1024` (20mb);

@@ -324,0 +324,0 @@ limit the amount of memory all fields together (except files) can allocate in

@@ -69,2 +69,3 @@ /* eslint-disable class-methods-use-this */

'_parser',
'req',
].forEach((key) => {

@@ -114,32 +115,34 @@ this[key] = null;

parse(req, cb) {
this.pause = () => {
try {
req.pause();
} catch (err) {
// the stream was destroyed
if (!this.ended) {
// before it was completed, crash & burn
this._error(err);
}
return false;
pause () {
try {
this.req.pause();
} catch (err) {
// the stream was destroyed
if (!this.ended) {
// before it was completed, crash & burn
this._error(err);
}
return true;
};
return false;
}
return true;
}
this.resume = () => {
try {
req.resume();
} catch (err) {
// the stream was destroyed
if (!this.ended) {
// before it was completed, crash & burn
this._error(err);
}
return false;
resume () {
try {
this.req.resume();
} catch (err) {
// the stream was destroyed
if (!this.ended) {
// before it was completed, crash & burn
this._error(err);
}
return false;
}
return true;
};
return true;
}
parse(req, cb) {
this.req = req;
// Setup callback first, so we don't miss anything from data events emitted immediately.

@@ -149,3 +152,2 @@ if (cb) {

this.fields = {};
let mockFields = '';
const files = {};

@@ -205,3 +207,2 @@

}
this._maybeEnd();
});

@@ -252,12 +253,2 @@

pause() {
// this does nothing, unless overwritten in IncomingForm.parse
return false;
}
resume() {
// this does nothing, unless overwritten in IncomingForm.parse
return false;
}
onPart(part) {

@@ -420,11 +411,8 @@ // this method can be overwritten by the user

const results = [];
const _dummyParser = new DummyParser(this, this.options);
// eslint-disable-next-line no-plusplus
for (let idx = 0; idx < this._plugins.length; idx++) {
const plugin = this._plugins[idx];
new DummyParser(this, this.options);
const results = [];
this._plugins.forEach((plugin, idx) => {
let pluginReturn = null;
try {

@@ -443,3 +431,2 @@ pluginReturn = plugin(this, this.options) || this;

}
Object.assign(this, pluginReturn);

@@ -449,22 +436,7 @@

this.emit('plugin', idx, pluginReturn);
results.push(pluginReturn);
}
});
this.emit('pluginsResults', results);
// NOTE: probably not needed, because we check options.enabledPlugins in the constructor
// if (results.length === 0 /* && results.length !== this._plugins.length */) {
// this._error(
// new Error(
// `bad content-type header, unknown content-type: ${this.headers['content-type']}`,
// ),
// );
// }
}
_error(err, eventName = 'error') {
// if (!err && this.error) {
// this.emit('error', this.error);
// return;
// }
if (this.error || this.ended) {

@@ -474,10 +446,9 @@ return;

this.req = null;
this.error = err;
this.emit(eventName, err);
if (Array.isArray(this.openedFiles)) {
this.openedFiles.forEach((file) => {
file.destroy();
});
}
this.openedFiles.forEach((file) => {
file.destroy();
});
}

@@ -597,3 +568,3 @@

_setUpMaxFields() {
if (this.options.maxFields !== 0) {
if (this.options.maxFields !== Infinity) {
let fieldsCount = 0;

@@ -634,9 +605,6 @@ this.on('field', () => {

_maybeEnd() {
// console.log('ended', this.ended);
// console.log('_flushing', this._flushing);
// console.log('error', this.error);
if (!this.ended || this._flushing || this.error) {
return;
}
this.req = null;
this.emit('end');

@@ -643,0 +611,0 @@ }

@@ -17,2 +17,4 @@ /* eslint-disable no-underscore-dangle */

}
return self;
};

@@ -19,0 +21,0 @@

@@ -36,2 +36,3 @@ /* eslint-disable no-underscore-dangle */

}
return self;
}

@@ -38,0 +39,0 @@

@@ -17,3 +17,2 @@ /* eslint-disable no-underscore-dangle */

}
return self;

@@ -20,0 +19,0 @@ }

@@ -18,3 +18,2 @@ /* eslint-disable no-underscore-dangle */

}
return self;

@@ -21,0 +20,0 @@ };

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc