-
Notifications
You must be signed in to change notification settings - Fork 328
Do more conservative URL normalization #758
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ixti
reviewed
Aug 28, 2023
ixti
requested changes
Aug 28, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This is great. Can you please move NORMALIZER proc spec in a separate file though, to follow RSpec naming conventions? And, please, add @private
documentation tag to self.percent_encode
Done :-) |
tarcieri
approved these changes
Oct 6, 2023
1 task
jcoyne
added a commit
to sul-dlss/stacks
that referenced
this pull request
Mar 27, 2025
This issue was fixed in httprb/http#758
jcoyne
added a commit
to sul-dlss/stacks
that referenced
this pull request
Mar 27, 2025
This issue was fixed in httprb/http#758
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
http.rb normalises URLs before making a request. This normalisation may reformat a perfectly valid URL. Even though the normalised URL in theory is equivalent to the original URL, some servers may not recognise this (see e.g. mastodon/mastodon#26219).
Some of these problems are due to a bug in Addressable (see sporkmonger/addressable#366). But even with that bug fixes, there is no reason to normalise the URL before fetching it, apart from fixing obviously invalid aspects such as spaces in the path. There is no benefit, only potential problems.
I suggest we take a more conservative approach and only escape characters in path and query outside the printable ASCII range, and never decode any existing percent-escape sequences. This is the approach taken by cURL, so that seems like a safe bet.
If somebody wants more “aggressive” normalisation for better caching in HTTP proxies or whatever, and they are aware of the risks connected with this, they can provide a custom normaliser or just call
Addressable::URI#normalize
before invoking htp.rb. But I don't think such potentially risky behaviour should be the default.Fixes #654