aio-libs / aio-libs/yarl

Requoting unquotes %27

Open
#1,077 5 comments 0 reactions 0 assignees View on GitHub
bug dependencies
Dominant language
Python
Stars
1.5k
Forks
215
Avg merge
1d 2m
Merged PRs (30d)
13

Description

### 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
```python
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`
```python
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

```python
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

```python-traceback
N/A
```

### Python Version

```console
$ python --version
Python 3.9.7
```

### aiohttp Version

```console
$ python -m pip show aiohttp
Version: 3.8.1
```

### multidict Version

```console
$ python -m pip show multidict
Version: 5.2.0
```

### yarl Version

```console
$ 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.