Repository navigation
Only treat :// as a scheme separator before the path - #2701
Merged
Merged
Conversation
parse_url looked for :// anywhere, so a redirect to a path whose query held a URL, such as /login?next=https://example.com/, was split at the query and rejected because the scheme was not letters only.
The redirect test resolves its relative case to the same input shape, and the case with a leading slash did not fit the test's name.
Owner
|
Thanks! |
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
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.
parse_url searches the whole string for :// and treats everything before it as the scheme. This breaks redirects to paths with another URL in the query, such as /login?next=https://example.com/ or the relative next?source=https://example.com/catalog. The scheme becomes /dir/next?source=https and fails the letters-only check. The redirect is not followed and the client returns Error::Unknown. A scheme can only appear before the first / or ? or #. The change makes parse_url treat :// as the separator only when it appears before any of them.
I added both forms to RedirectTest.RelativeLocationWithoutLeadingSlash. With the old httplib.h the test fails on the query case with Unknown. With the change it passes along with the other RedirectTest and URL tests. All 37 tests were built with the test Makefile and ASan.