Improve content disposition regexp.

This commit is contained in:
André Cruz
2013-05-01 15:35:05 +01:00
parent 0c7e593370
commit 93eba6ef68
3 changed files with 64 additions and 9 deletions

View File

@@ -141,8 +141,13 @@ UrlResolver.prototype._parseHeaders = function (file, response) {
return Q.resolve([file, response]);
}
// If so, extract the filename
matches = disposition.match(/filename="?(.+?)"?/i);
// If so, extract the filename from it
// Since there's various security issues with parsing this header,
// we only interpret word chars plus dots, dashes and spaces
// Also the filename can't start with a space and end with a
// dot or a space (this is known to cause issues in Windows)
// See: http://superuser.com/questions/230385/dots-at-end-of-file-name
matches = disposition.match(/filename="?([\w\.\-](?:[\w\.\- ]*[\w\-]))"?/i);
if (!matches) {
return Q.resolve([file, response]);
}