Bracketed authority ending in @ raises IndexError
- Vorherrschende Sprache
- Python
- Sterne
- 1.5k
- Forks
- 215
- Ø Merge
- 1 T. 2 Min.
- Gemergte PRs (30 T.)
- 13
Beschreibung
### Please confirm the following
- [x] I agree to follow the [aio-libs Code of Conduct][CoC]
[CoC]: ../../.github/blob/master/CODE_OF_CONDUCT.md
- [x] I have checked the [current issues][issue search] for duplicates.
[issue search]: ../search?q=is%3Aissue&type=issues
- [x] I understand this is open source software provided for free and that I might not receive a timely response.
- [x] I am positive I am **NOT** reporting a (potential) security
vulnerability, to the best of my knowledge. *(These must be shared by
submitting [this report form][vulnerability report form] instead, if
any hesitation exists.)*
[vulnerability report form]: ../security/advisories/new
- [x] I am willing to submit a pull request with reporoducers as xfailing test cases or even entire fix. *(Assign this issue to me.)*
### Describe the bug
The bug is similar to the previously fixed #1485
Malformed authorities containing brackets and ending in `@` raise `IndexError` during `URL()` construction. Malformed URLs normally produce a URL-specific `ValueError`; exposing an internal string subscript error makes validation unnecessarily difficult for callers.
### To Reproduce
```python
from yarl import URL
for value in ("http://[::1]@", "//[]@", "//a[b]c@"):
try:
URL(value)
except Exception as exc:
print(repr(value), type(exc).__name__, str(exc))
```
### Expected behavior
Reject these malformed authorities with `ValueError`, consistent with other invalid bracketed hosts
### Logs/tracebacks
```python-traceback
'http://[::1]@' IndexError string index out of range
'//[]@' IndexError string index out of range
'//a[b]c@' IndexError string index out of range
```
### Python Version
```console
$ python --version
3.12.3
```
### multidict Version
```console
$ python -m pip show multidict
6.7.1
```
### propcache Version
```console
$ python -m pip show propcache
0.4.1
```
### yarl Version
```console
$ python -m pip show yarl
1.24.5, commit `577e75f`
```
### OS
Linux 6.6.87.2, WSL2, x86-64
### Additional context
_No response_
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.