Skip to content

fix: escape file names once on the HTML index pages - #2343

Merged
nedbat merged 1 commit into
coveragepy:mainfrom
Thanatos9404:templite-autoescape
Oct 25, 2026
Merged

nedbat merged 1 commit into
coveragepy:mainfrom
Thanatos9404:templite-autoescape

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The file, function and class index pages escaped file names twice: html.py stored escape(filename) in IndexItem and index.html applied the escape filter again, so a&b.py was listed as a&b.py.

html.py now stores the raw name and the template's escape filter does the escaping, with no change to Templite. The new test checks the file and function index pages and fails on main. Tested with tests/test_html.py and tests/test_templite.py, ruff, pylint and mypy.

@nedbat

nedbat commented Oct 22, 2026

Copy link
Copy Markdown
Member

Thanks for this. I would rather not change templite, since it is unaware of the meaning of its templates. So a smaller fix would be better.

html.py stored escape(filename) in IndexItem and index.html applied
the escape filter again, so a file named a&b.py was listed on the
file, function and class index pages as a&b.py. Store the raw
name and let the template escape it.
@Thanatos9404 Thanatos9404 changed the title fix: escape values in the HTML report templates by default fix: escape file names once on the HTML index pages Oct 22, 2026
@Thanatos9404

Copy link
Copy Markdown
Contributor Author

That makes sense. I've switched the PR to the small fix: html.py now stores the raw file name and the template's escape filter is the only escaping, so Templite is untouched.

@nedbat
nedbat merged commit ebeba6e into coveragepy:main Oct 25, 2026
63 checks passed
nedbat added a commit that referenced this pull request Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants