fix: don't over-escape page title#804
Open
crowlbot wants to merge 1 commit into
Open
Conversation
|
|
crowlKats
approved these changes
Jun 5, 2026
The page <title> was rendered with the registry-wide handlebars escaper (html_escape::encode_safe), which escapes characters that are harmless in text content such as '/'. This turned titles like "I/O" into "I/O". Render the title via a dedicated escape_text helper that only escapes the characters meaningful in text content (&, < and >), so a title reads as "I/O" while HTML-special characters in symbol names stay escaped.
30dc0d2 to
a721934
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The page
<title>was rendered with the registry-wide handlebars escaper (html_escape::encode_safe), which escapes characters that are harmless in plain text content — most notably/. As a result a module/symbol/package name likeI/Owas rendered as:Fix
Render the title through a small
escape_texthandlebars helper that only escapes the characters that are meaningful in text content (&,<,>). The title now reads:HTML-special characters in symbol names are still escaped, so a title can never break out of the
<title>element. The existing XSS fixture (Foo.prototype."><img src=x onerror=alert(1)>) confirms this:<and>remain</>; only the now-unnecessary"is dropped.The registry-wide escaper is intentionally left unchanged, so escaping of attribute/URL values elsewhere on the page is unaffected.
Tests
Added two regression tests to
tests/html_test.rs:title_does_not_over_escape_slash— a scoped package name (@deno/cool) renders an unescaped/in the title.title_escapes_html_special_chars— a property name containing<script>is still escaped in the title.Fixes #647