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

[Bug 1753838] Harden trailing slashes redirect #360

Merged
merged 4 commits into from Feb 7, 2022

Conversation

gbrownmozilla
Copy link
Contributor

No description provided.

@gbrownmozilla gbrownmozilla self-assigned this Feb 7, 2022
@gbrownmozilla gbrownmozilla marked this pull request as ready for review February 7, 2022 21:47
if request.path.endswith('/'):
return web.HTTPFound('/' + request.path.strip('/'))
return web.HTTPFound('/' + request.path.strip('/'+string.whitespace))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that this will fix the issue?
This seems like a good candidate for a unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added unit tests now - thanks.
Running locally, I reproduced the issue reported in bug 1753838 with requests like http://localhost:9876/%0a/www.google.com/. Without changes, that redirects to www.google.com; with this patch, pollbot reports:
{"status": 404, "message": "Page '/www.google.com' not found"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to hear, thank you!

@gbrownmozilla gbrownmozilla changed the title Harden trailing slashes redirect [Bug 1753838] Harden trailing slashes redirect Feb 7, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants