Skip to content

Commit 4e2a944

Browse files
committed
Backport redirect vuln fix
1 parent f5a173d commit 4e2a944

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/ecstatic.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ var ecstatic = module.exports = function (dir, options) {
144144
}
145145

146146
// 302 to / if necessary
147-
if (!parsed.pathname.match(/\/$/)) {
147+
if (!pathname.match(/\/$/)) {
148148
res.statusCode = 302;
149149
res.setHeader('location', parsed.pathname + '/' +
150150
(parsed.query? ('?' + parsed.query):'')
@@ -384,15 +384,15 @@ function shouldCompress(req) {
384384
function decodePathname(pathname) {
385385
var pieces = pathname.replace(/\\/g,"/").split('/');
386386

387-
return pieces.map(function (piece) {
387+
return path.normalize(pieces.map(function (piece) {
388388
piece = decodeURIComponent(piece);
389389

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

394394
return piece;
395-
}).join('/');
395+
}).join('/'));
396396
}
397397

398398
if (!module.parent) {

0 commit comments

Comments
 (0)