Skip to content

fix: treat numeric character reference CR as whitespace - #1832

Open
Steve0x2a wants to merge 1 commit into
inikulin:masterfrom
Steve0x2a:fix/cr-ncr-whitespace
Open

fix: treat numeric character reference CR as whitespace#1832
Steve0x2a wants to merge 1 commit into
inikulin:masterfrom
Steve0x2a:fix/cr-ncr-whitespace

Conversation

@Steve0x2a

Copy link
Copy Markdown

A leading 
 / 
 was emitted as a CHARACTER token because isWhitespace() did not include U+000D. Literal CRs are rewritten to LF by the preprocessor, so this only showed up for numeric character references.

The before-html / before-head / in-head / after-head insertion modes then treated that token as “anything else” and inserted a stray CR text node in <body> instead of ignoring it.

This adds CARRIAGE_RETURN to isWhitespace. It does not rewrite NCR 0x0D to LF — the spec reports that as controlCharacterReference and keeps U+000D.

Reported and diagnosed by @maximilliangrand.

Fixes #1828

isWhitespace omitted U+000D. Literal CRs are preprocessed to LF, but
&inikulin#13; / &#x0D; bypass the preprocessor and were emitted as CHARACTER
tokens, inserting a stray CR text node before body.

Credit @maximilliangrand for the report.

Fixes inikulin#1828
@Steve0x2a Steve0x2a changed the title Treat CR numeric character references as whitespace fix: treat numeric character reference CR as whitespace Aug 18, 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.

Numeric character reference for CR (&#13;) not treated as whitespace, inserts a stray text node before <body>

1 participant