Latest Results
Strip trailing C0 control or space from parsed URLs (#1936)
<!-- Thank you for your contribution! -->
## What do these changes do?
`split_url()` stripped only leading C0 control characters and spaces,
following a comment copied from `urllib.parse.urlsplit`, and
percent-encoded the trailing ones: `URL("http://h/p ")` printed as
`http://h/p%20`. It now strips both ends in both modes. For WHATWG mode
this is the basic URL parser. For RFC 3986 mode the strict grammar
rejects such input, but RFC 3986 appendix C asks software that accepts
user-typed URIs to strip surrounding whitespace, and RFC mode already
stripped the leading side and dropped tabs and newlines.
In `tools/conformance/REPORT.md`, four rows move from "All three differ"
to "RFC 3986 differs, yarl follows WHATWG" (`' foo.com '`, `'\t :foo.com
\n'`, `non-special:opaque `, and one with leading and trailing control
characters). Two rows of that category stay because of unrelated
differences (query spaces encoded as `+`, and `c|` drive letters). The
"yarl differs, RFC 3986 and WHATWG agree" section is unchanged.
## Are there changes in behavior for the user?
Yes. Trailing C0 control characters and spaces in a parsed URL string
are dropped instead of being percent-encoded, in both `encoded=False`
and `encoded=True` parsing and in both modes.
## Is it a substantial burden for the maintainers to support this?
No, it replaces `lstrip` with `strip`.
## Related issue number
Follow-up to #1923.
## Checklist
- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes
- [ ] If you provide code modification, please add yourself to
`CONTRIBUTORS.txt`
- [x] Add a new news fragment into the `CHANGES/` folder
Drafted with Claude Code (Claude Opus 5.5); reviewed by @asvetlov.
<details>
<summary>Agent run details (optional, for reviewers)</summary>
Tests: `pytest ./tests ./yarl -n auto` with the C extension: 2503
passed, 131 skipped, 57 xfailed; with `YARL_NO_EXTENSIONS=1`: 2120
passed, 138 skipped, 55 xfailed.
Conformance: `python tools/conformance/compare.py --check` passes after
`make conformance`.
Docs: sphinx doctest 192 tests, 0 failures; the spelling build shows
only local false positives in `index.rst` contractions, which are
unrelated.
Lint: `pre-commit run` on the changed files passes, including mypy.
</details> Latest Branches
0%
asvetlov:conformance-mode-aware 0%
asvetlov:special-authority-no-slashes 0%
asvetlov:strip-trailing-space Ā© 2026 CodSpeed Technology