Skip to content

Only treat :// as a scheme separator before the path - #2701

Merged
yhirose merged 2 commits into
yhirose:masterfrom
emincan2000:redirect-query-scheme
Nov 27, 2026
Merged

yhirose merged 2 commits into
yhirose:masterfrom
emincan2000:redirect-query-scheme

Conversation

@emincan2000

Copy link
Copy Markdown
Contributor

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.

emincan2000 and others added 2 commits November 27, 2026 13:12
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.
@yhirose
yhirose merged commit 74180f0 into yhirose:master Nov 27, 2026
27 of 28 checks passed
@yhirose

yhirose commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

2 participants