Skip to content

Commit

Permalink
Backport redirect vuln fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhbrook committed May 3, 2019
1 parent f5a173d commit 4e2a944
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/ecstatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ var ecstatic = module.exports = function (dir, options) {
}

// 302 to / if necessary
if (!parsed.pathname.match(/\/$/)) {
if (!pathname.match(/\/$/)) {
res.statusCode = 302;
res.setHeader('location', parsed.pathname + '/' +
(parsed.query? ('?' + parsed.query):'')
Expand Down Expand Up @@ -384,15 +384,15 @@ function shouldCompress(req) {
function decodePathname(pathname) {
var pieces = pathname.replace(/\\/g,"/").split('/');

return pieces.map(function (piece) {
return path.normalize(pieces.map(function (piece) {
piece = decodeURIComponent(piece);

if (process.platform === 'win32' && /\\/.test(piece)) {
throw new Error('Invalid forward slash character');
}

return piece;
}).join('/');
}).join('/'));
}

if (!module.parent) {
Expand Down

0 comments on commit 4e2a944

Please sign in to comment.