Skip to content

Commit af6bd44

Browse files
committed
Fixed incorrect capturing groups
1 parent c2120e1 commit af6bd44

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/incoming_form.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {
356356
var m = headerValue.match(/\bname=("([^"]*)"|([^\(\)<>@,;:\\"\/\[\]\?=\{\}\s\t/]+))/i);
357357
if (headerField == 'content-disposition') {
358358
if (m) {
359-
part.name = m[1];
359+
part.name = m[2] || m[3] || '';
360360
}
361361

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

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

0 commit comments

Comments
 (0)