yarl: URL.build doesn't url encode credentials
EDIT the bug described here is just a consequence of the bug described below.
Currently square brackets in the username or the password lead to the URL being interpreted as an IPv6 address:
>>> yarl.URL("https://x:[@localhost")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hynek/.virtualenvs/ansible-tools/lib/python3.6/site-packages/yarl/__init__.py", line 149, in __init__
val = urlsplit(val)
File "/Users/hynek/.pyenv/versions/3.6.3/lib/python3.6/urllib/parse.py", line 439, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL
Invalid IPv6 URL
>>> yarl.URL("https://[:x@localhost")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hynek/.virtualenvs/ansible-tools/lib/python3.6/site-packages/yarl/__init__.py", line 149, in __init__
val = urlsplit(val)
File "/Users/hynek/.pyenv/versions/3.6.3/lib/python3.6/urllib/parse.py", line 439, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL
Invalid IPv6 URL
Sadly, the error seems to come from the stdlib tho:
>>> p.urlsplit("https://x:[@localhost")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hynek/.pyenv/versions/3.6.3/lib/python3.6/urllib/parse.py", line 439, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL
Invalid IPv6 URL
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (14 by maintainers)
(just to be clear: I ran into my original bug because I tried to parse an URL that I’ve created using URL.build() 😃)