Repository navigation
Potential issue: dot-segment removal drops the trailing slash (RFC 3986 section 5.2.4), so "http://e.org/a/.." != "http://e.org/" #3819
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 normalization.
httpx._urlparse.normalize_pathclaims to implement RFC 3986 section 5.2.4, but a trailing "." or ".." segment loses its trailing slash:User-visible consequence:
Browsers (WHATWG) agree with the RFC here. The existing tests pin mid-path cases ("/abc/def/../ghi/./jkl" -> "/abc/ghi/jkl") but nothing with a trailing dot segment. Note the docstring example itself would change under a strict reading: normalize_path("/path/./to/somewhere/..") is currently documented as "/path/to", where the RFC algorithm gives "/path/to/" — so I wanted to check whether the current behaviour is a deliberate simplification before sending a PR.
The fix is ready on a fork branch: https://github.com/Sun-Wukhan/httpx/tree/fix/url-normalize-path-rfc (the full tests/models suite passes with it). Raising it here first since PR creation on this repo is limited to collaborators; happy for a maintainer to open the PR from the branch.
All reactions