Skip to content

Commit

Permalink
Fixed incorrect capturing groups
Browse files Browse the repository at this point in the history
  • Loading branch information
TanukiSharp committed Sep 2, 2015
1 parent c2120e1 commit af6bd44
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/incoming_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {
var m = headerValue.match(/\bname=("([^"]*)"|([^\(\)<>@,;:\\"\/\[\]\?=\{\}\s\t/]+))/i);
if (headerField == 'content-disposition') {
if (m) {
part.name = m[1];
part.name = m[2] || m[3] || '';
}

part.filename = self._fileName(headerValue);
Expand Down Expand Up @@ -426,7 +426,8 @@ IncomingForm.prototype._fileName = function(headerValue) {
var m = headerValue.match(/\bfilename=("(.*?)"|([^\(\)<>@,;:\\"\/\[\]\?=\{\}\s\t/]+))($|;\s)/i);
if (!m) return;

var filename = m[1].substr(m[1].lastIndexOf('\\') + 1);
var match = m[2] || m[3] || '';
var filename = match.substr(match.lastIndexOf('\\') + 1);
filename = filename.replace(/%22/g, '"');
filename = filename.replace(/&#([\d]{4});/g, function(m, code) {
return String.fromCharCode(code);
Expand Down

0 comments on commit af6bd44

Please sign in to comment.