formidable
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -59,2 +59,7 @@ if (global.GENTLY) require = GENTLY.hijack(require); | ||
} | ||
if (this._writeStream.closed) { | ||
return cb(); | ||
} | ||
this._writeStream.write(buffer, function() { | ||
@@ -61,0 +66,0 @@ self.lastModifiedDate = new Date(); |
@@ -28,2 +28,3 @@ if (global.GENTLY) require = GENTLY.hijack(require); | ||
this.maxFieldsSize = opts.maxFieldsSize || 2 * 1024 * 1024; | ||
this.maxFileSize = opts.maxFileSize || 2 * 1024 * 1024; | ||
this.keepExtensions = opts.keepExtensions || false; | ||
@@ -43,2 +44,3 @@ this.uploadDir = opts.uploadDir || (os.tmpdir && os.tmpdir()) || os.tmpDir(); | ||
this._fieldsSize = 0; | ||
this._fileSize = 0; | ||
this.openedFiles = []; | ||
@@ -185,2 +187,3 @@ | ||
// This MUST check exactly for undefined. You can not change it to !part.filename. | ||
if (part.filename === undefined) { | ||
@@ -220,2 +223,7 @@ var value = '' | ||
part.on('data', function(buffer) { | ||
self._fileSize += buffer.length; | ||
if (self._fileSize > self.maxFileSize) { | ||
self._error(new Error('maxFileSize exceeded, received '+self._fileSize+' bytes of file data')); | ||
return; | ||
} | ||
if (buffer.length == 0) { | ||
@@ -473,3 +481,3 @@ return; | ||
file.open(); | ||
this.openedFiles.push(file); | ||
this._flushing++; | ||
@@ -523,6 +531,2 @@ | ||
if (this.bytesExpected) { | ||
parser.initWithLength(this.bytesExpected); | ||
} | ||
parser.onField = function(key, val) { | ||
@@ -561,2 +565,1 @@ self.emit('field', key, val); | ||
}; | ||
@@ -7,3 +7,3 @@ if (global.GENTLY) require = GENTLY.hijack(require); | ||
this.parent = parent; | ||
this.data = new Buffer(''); | ||
this.chunks = []; | ||
this.bytesWritten = 0; | ||
@@ -13,13 +13,5 @@ } | ||
JSONParser.prototype.initWithLength = function(length) { | ||
this.data = new Buffer(length); | ||
}; | ||
JSONParser.prototype.write = function(buffer) { | ||
if (this.data.length >= this.bytesWritten + buffer.length) { | ||
buffer.copy(this.data, this.bytesWritten); | ||
} else { | ||
this.data = Buffer.concat([this.data, buffer]); | ||
} | ||
this.bytesWritten += buffer.length; | ||
this.chunks.push(buffer); | ||
return buffer.length; | ||
@@ -30,3 +22,3 @@ }; | ||
try { | ||
var fields = JSON.parse(this.data.toString('utf8')); | ||
var fields = JSON.parse(Buffer.concat(this.chunks)); | ||
for (var field in fields) { | ||
@@ -33,0 +25,0 @@ this.onField(field, fields[field]); |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"devDependencies": { | ||
@@ -24,5 +24,2 @@ "gently": "^0.8.0", | ||
}, | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"repository": { | ||
@@ -35,4 +32,3 @@ "type": "git", | ||
}, | ||
"optionalDependencies": {}, | ||
"license": "MIT" | ||
"optionalDependencies": {} | ||
} |
@@ -31,3 +31,3 @@ # Formidable | ||
This is a low level package, and if you're using a high level framework such as Express, chances are it's already included in it. You can [read this discussion](http://stackoverflow.com/questions/11295554/how-to-disable-express-bodyparser-for-file-uploads-node-js) about how Formidable is integrated with Express. | ||
This is a low-level package, and if you're using a high-level framework it may already be included. However, [Express v4](http://expressjs.com) does not include any multipart handling, nor does [body-parser](https://github.com/expressjs/body-parser). | ||
@@ -34,0 +34,0 @@ Note: Formidable requires [gently](http://github.com/felixge/node-gently) to run the unit tests, but you won't need it for just using the library. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
143530
893
0