Skip to content

Commit

Permalink
Merge pull request #193 from egirshov/issue-163
Browse files Browse the repository at this point in the history
Test case for #163
  • Loading branch information
svnlto committed Feb 7, 2013
2 parents 74ac115 + 7648a17 commit 5980a64
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/incoming_form.js
Expand Up @@ -310,7 +310,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {

var m;
if (headerField == 'content-disposition') {
if (m = headerValue.match(/name="([^"]+)"/i)) {
if (m = headerValue.match(/\bname="([^"]+)"/i)) {
part.name = m[1];
}

Expand Down Expand Up @@ -377,7 +377,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {
};

IncomingForm.prototype._fileName = function(headerValue) {
var m = headerValue.match(/filename="(.*?)"($|; )/i);
var m = headerValue.match(/\bfilename="(.*?)"($|; )/i);
if (!m) return;

var filename = m[1].substr(m[1].lastIndexOf('\\') + 1);
Expand Down
13 changes: 13 additions & 0 deletions test/fixture/http/no-filename/filename-name.http
@@ -0,0 +1,13 @@
POST /upload HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG
Content-Length: 1000

------WebKitFormBoundarytyE4wkKlZ5CQJVTG
Content-Disposition: form-data; filename="plain.txt"; name="upload"
Content-Type: text/plain

I am a plain text file

------WebKitFormBoundarytyE4wkKlZ5CQJVTG--

4 changes: 4 additions & 0 deletions test/fixture/js/no-filename.js
@@ -1,3 +1,7 @@
module.exports['generic.http'] = [
{type: 'file', name: 'upload', filename: '', fixture: 'plain.txt'},
];

module.exports['filename-name.http'] = [
{type: 'file', name: 'upload', filename: 'plain.txt', fixture: 'plain.txt'},
];

0 comments on commit 5980a64

Please sign in to comment.