Skip to content

fix: don't over-escape page title#804

Open
crowlbot wants to merge 1 commit into
mainfrom
fix-title-over-escaping
Open

fix: don't over-escape page title#804
crowlbot wants to merge 1 commit into
mainfrom
fix-title-over-escaping

Conversation

@crowlbot

@crowlbot crowlbot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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 like I/O was rendered as:

<title>I&#x2F;O - Deno documentation</title>

Fix

Render the title through a small escape_text handlebars helper that only escapes the characters that are meaningful in text content (&, <, >). The title now reads:

<title>I/O - Deno documentation</title>

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 &lt;/&gt;; only the now-unnecessary &quot; 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

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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&#x2F;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.
@crowlbot crowlbot force-pushed the fix-title-over-escaping branch from 30dc0d2 to a721934 Compare June 9, 2026 13:51
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.

Document title is incorrectly escaped

3 participants