Repository navigation
Potential issue: a leading ":" in a URL string is silently eaten, breaking round-tripping #3820
Unanswered
Sun-Wukhan
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Found while property-based testing URL parse/print round-trips.
The URL regex's scheme group can match empty, so a leading ':' is consumed as a scheme delimiter with an empty scheme. That also bypasses validate_path's own rule — "Relative URLs cannot have a path starting with ':'" — which is enforced for component-wise construction but not for string parsing.
One wrinkle: httpx.URL("://example.com") is pinned by an existing test (test_url_no_scheme) as a deliberately supported scheme-less authority form, so a fix has to reject ":foo" / ":http://..." while keeping "://example.com" working.
The fix is ready on a fork branch: https://github.com/Sun-Wukhan/httpx/tree/fix/url-leading-colon (the full tests/models suite passes with it). Raising it here first since PR creation on this repo is limited to collaborators. Happy either way — mainly wanted to check this isn't intentional leniency.
All reactions