Emit style and script contents as raw text - #389
Merged
Merged
Conversation
brainkim
force-pushed
the
fix/html-raw-text
branch
4 times, most recently
from
September 14, 2026 14:52
40ed959 to
6d18769
Compare
Text children of style and script were entity-escaped like any other text, but browsers never decode character references inside raw text elements, so the CSS and code shipped broken — and hydration silently patched the text on pages with client JavaScript, hiding the bug. Their contents now render verbatim, with a closing tag sequence neutralized as an identity escape valid in CSS, JavaScript strings, and JSON. Escaping stays for style and script inside inline SVG, where the parser does decode entities, and for title and textarea as escapable raw text. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019pggktip8wsuxzy2VCY9p7
brainkim
force-pushed
the
fix/html-raw-text
branch
from
September 14, 2026 17:20
6d18769 to
154cdeb
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.
Browsers never decode character references inside
<style>and<script>, but the HTML renderer escaped their text like any other, so served CSS and code were broken. Hydration patched the text on pages with client JavaScript, hiding the bug; static pages stayed broken. Found via bikeshaving.org's stylesheet.A closing tag sequence is neutralized, case-preservingly, with an identity escape valid in CSS, JavaScript strings, and JSON:
So JSON-LD and import maps round-trip:
Escaping stays where the parser does decode entities — style/script inside inline SVG (foreign content) and
<title>/<textarea>(escapable raw text):RawandinnerHTMLare unchanged. Mechanically,text()keeps the raw string alongside the escaped one andarrange(), which knows the tag and scope, chooses.Nine new tests (raw output, neutralizations, the carve-outs, a JSON-LD round-trip, a zero-warning hydration case). One docs paragraph:
Rawis no longer needed for style/script, except a dynamic script body containing<!--together with<script. CHANGELOG entry; skill references regenerated.🤖 Generated with Claude Code
https://claude.ai/code/session_019pggktip8wsuxzy2VCY9p7