Skip to content

Keep a // path from becoming an authority on unsplit - #155

Open
gyanu2507 wants to merge 1 commit into
python-hyper:mainfrom
gyanu2507:fix/unsplit-network-path
Open

Keep a // path from becoming an authority on unsplit#155
gyanu2507 wants to merge 1 commit into
python-hyper:mainfrom
gyanu2507:fix/unsplit-network-path

Conversation

@gyanu2507

Copy link
Copy Markdown

scheme:/..///bar has no authority. Removing dot-segments leaves path //bar, and unsplit() then emits scheme://bar. Parsing that string treats bar as the host.

If there is no authority and the path starts with //, prefix /. so the reconstituted URI still has no host. Same idea as the WHATWG serializer for a path whose first segment is empty.

>>> from rfc3986 import uri_reference
>>> uri_reference("scheme:/..///bar").normalize().unsplit()
# before: "scheme://bar"
# after:  "scheme:/.//bar"
>>> uri_reference("scheme:/.//bar").authority
None

scheme:/..///bar has no host. After stripping dot-segments the path is
//bar, and joining that back as scheme://bar makes the next parse take
bar as the authority. Prefix /. so the string still has no host.

Fixes python-hyper#85
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.

1 participant