Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix: Handle quotes in filenames

  • Loading branch information...
commit 7b6094288726760f44e8232a543277a50c016dd4 1 parent 6ccf2d5
@felixge authored
View
2  lib/formidable/incoming_form.js
@@ -273,7 +273,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {
part.name = m[1];
}
- if (m = headerValue.match(/filename="([^"]+)"/i)) {
+ if (m = headerValue.match(/filename="([^;]+)"/i)) {
part.filename = m[1].substr(m[1].lastIndexOf('\\') + 1);
}
} else if (headerField == 'content-type') {
View
6 test/simple/test-incoming-form.js
@@ -435,12 +435,12 @@ test(function _initMultipart() {
gently.expect(form, 'onPart', function(part) {
assert.deepEqual
( part.headers
- , { 'content-disposition': 'form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sunset.jpg"'
+ , { 'content-disposition': 'form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sun"et.jpg"'
, 'content-type': 'text/plain'
}
);
assert.equal(part.name, 'field2');
- assert.equal(part.filename, 'Sunset.jpg');
+ assert.equal(part.filename, 'Sun"et.jpg');
assert.equal(part.mime, 'text/plain');
gently.expect(part, 'emit', function(event, b) {
@@ -455,7 +455,7 @@ test(function _initMultipart() {
PARSER.onPartBegin();
PARSER.onHeaderField(new Buffer('content-disposition'), 0, 19);
- PARSER.onHeaderValue(new Buffer('form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sunset.jpg"'), 0, 85);
+ PARSER.onHeaderValue(new Buffer('form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sun"et.jpg"'), 0, 85);
PARSER.onHeaderEnd();
PARSER.onHeaderField(new Buffer('Content-Type'), 0, 12);
PARSER.onHeaderValue(new Buffer('text/plain'), 0, 10);
Please sign in to comment.
Something went wrong with that request. Please try again.