yarl
yarl copied to clipboard
Requoting unquotes %27
Describe the bug
When requoting a redirection URL, you use yarl.URL
and the single quotation mark gets unquoted: %27
=> '
https://github.com/aio-libs/aiohttp/blob/4635161ee8e7ad321cca46e01ce5bfeb1ad8bf26/aiohttp/client.py#L578-L580
In [1]: from yarl import URL
In [2]: url = "https://netloc/path?param=param%27%27value"
In [3]: print(url)
Out[3]: 'https://netloc/path?param=param%27%27value'
In [4]: print(str(URL(url)))
Out[4]: "https://netloc/path?param=param''value"
However, the requests
library does not unquote %27
: %27
=> %27
In [1]: from requests.utils import requote_uri
In [2]: url = "https://netloc/path?param=param%27%27value"
In [3]: print(url)
Out[3]: 'https://netloc/path?param=param%27%27value'
In [4]: print(requote_uri(url))
Out[4]: 'https://netloc/path?param=param%27%27value'
To Reproduce
from requests.utils import requote_uri
from yarl import URL
url = "https://netloc/path?param=param%27%27value"
print(url)
print(requote_uri(url))
print(URL(url))
Expected behavior
I think both libraries should have the same behavior.
Logs/tracebacks
N/A
Python Version
$ python --version
Python 3.9.7
aiohttp Version
$ python -m pip show aiohttp
Version: 3.8.1
multidict Version
$ python -m pip show multidict
Version: 5.2.0
yarl Version
$ python -m pip show yarl
Version: 1.7.2
OS
Ubuntu Linux
Related component
Client
Additional context
No response
Code of Conduct
- [X] I agree to follow the aio-libs Code of Conduct