Permalink
Browse files

Do not give a default filename when filename=""

That's because filename="" is also set when there is an empty file
input field, not just when using mozilla's incomplete FormData APIs.
  • Loading branch information...
1 parent 039f73c commit d7dbc455e2e8797beb9b4abcd71bff4276695cd8 @felixge committed Sep 21, 2011
Showing with 3 additions and 6 deletions.
  1. +2 −5 lib/incoming_form.js
  2. +1 −1 test/fixture/js/no-filename.js
View
7 lib/incoming_form.js
@@ -162,7 +162,7 @@ IncomingForm.prototype.onPart = function(part) {
IncomingForm.prototype.handlePart = function(part) {
var self = this;
- if (!part.filename) {
+ if (part.filename === undefined) {
var value = ''
, decoder = new StringDecoder(this.encoding);
@@ -293,10 +293,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {
part.name = m[1];
}
- var filename = self._fileName(headerValue);
- if (filename !== undefined) {
- part.filename = filename || part.name;
- }
+ part.filename = self._fileName(headerValue);
} else if (headerField == 'content-type') {
part.mime = headerValue;
}
View
2 test/fixture/js/no-filename.js
@@ -1,3 +1,3 @@
module.exports['generic.http'] = [
- {type: 'file', name: 'upload', filename: 'upload', fixture: 'plain.txt'},
+ {type: 'file', name: 'upload', filename: '', fixture: 'plain.txt'},
];

0 comments on commit d7dbc45

Please sign in to comment.