Permalink
Browse files

Fixed incorrect capturing groups

  • Loading branch information...
1 parent c2120e1 commit af6bd44464b67c8199997e279283f09c244f4880 @TanukiSharp TanukiSharp committed Sep 2, 2015
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/incoming_form.js
@@ -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);
@@ -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);

0 comments on commit af6bd44

Please sign in to comment.