Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Infinite 302 Redirection #260

Open
nashaofu opened this issue May 9, 2019 · 1 comment
Open

Windows Infinite 302 Redirection #260

nashaofu opened this issue May 9, 2019 · 1 comment

Comments

@nashaofu
Copy link

nashaofu commented May 9, 2019

return path.normalize(pieces.map((rawPiece) => {
const piece = decodeURIComponent(rawPiece);
if (process.platform === 'win32' && /\\/.test(piece)) {
throw new Error('Invalid forward slash character');
}
return piece;
}).join('/'));

Windows pathname parsing is incorrect

if (!pathname.match(/\/$/)) {
res.statusCode = 302;
const q = parsed.query ? `?${parsed.query}` : '';
res.setHeader('location', `${parsed.pathname}/${q}`);
res.end();
return;
}

Or modify here to

if (!parsed.pathname.match(/\/$/)) {
  res.statusCode = 302;
  const q = parsed.query ? `?${parsed.query}` : '';
  res.setHeader('location', `${parsed.pathname}/${q}`);
  res.end();
  return;
}
@bjornharrtell
Copy link

bjornharrtell commented Aug 7, 2019

Regressed in commit be6fc25 which was also backported to 3.x series with d0e2bcf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants