Skip to content

fix(compiler): parse named HTML entities containing digits#67229

Merged
mattrbeck merged 1 commit into
angular:mainfrom
yogeshwaran-c:fix/named-entity-digits
Mar 17, 2026
Merged

fix(compiler): parse named HTML entities containing digits#67229
mattrbeck merged 1 commit into
angular:mainfrom
yogeshwaran-c:fix/named-entity-digits

Conversation

@yogeshwaran-c

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Named HTML entities containing digits (e.g. ¹, ½, ▓, ∴) are not processed correctly by the Angular template compiler. Instead of being decoded to their corresponding Unicode characters, they are output as escaped text (e.g. ¹ instead of ¹).

This affects all 24 valid HTML named entities that contain digits in their names: blk12, blk14, blk34, emsp13, emsp14, frac12, frac13, frac14, frac15, frac16, frac18, frac23, frac25, frac34, frac35, frac38, frac45, frac56, frac58, frac78, sup1, sup2, sup3, there4.

Closes #51323

What is the new behavior?

The lexer's isNamedEntityEnd function now accepts digits as valid characters within named entity references, allowing all standard HTML named entities to be parsed and decoded correctly.

Additional context

The root cause was in the isNamedEntityEnd function in packages/compiler/src/ml_parser/lexer.ts. This function determines when to stop scanning a named entity reference. It used !chars.isAsciiLetter(code) as its termination condition, which meant any digit would immediately end the entity name scan. For an entity like ¹, the scanner would stop at sup (before the 1), never reach the semicolon, and fall back to treating the & as plain text.

The fix adds chars.isDigit(code) to the valid character check, so entity names like sup1 and frac12 are fully scanned.

The entity lookup table in entities.ts already contained all 24 entities — only the lexer scanning logic needed to be updated.

The lexer's isNamedEntityEnd function stopped scanning entity names
when encountering a digit character, causing 24 valid HTML named
entities with digits in their names (e.g. ¹, ½, ▓)
to be treated as plain text instead of decoded to their corresponding
Unicode characters.

Fixes angular#51323
@pullapprove pullapprove Bot requested a review from thePunderWoman February 23, 2026 21:04
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Feb 23, 2026
@ngbot ngbot Bot added this to the Backlog milestone Feb 23, 2026

@thePunderWoman thePunderWoman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JoostK JoostK added target: patch This PR is targeted for the next patch release action: presubmit The PR is in need of a google3 presubmit action: merge The PR is ready for merge by the caretaker labels Mar 17, 2026
@JeanMeche JeanMeche removed the action: presubmit The PR is in need of a google3 presubmit label Mar 17, 2026
@JeanMeche

Copy link
Copy Markdown
Member

I ran a TGP just in case. We're good to go !

@mattrbeck mattrbeck merged commit 75560ce into angular:main Mar 17, 2026
25 checks passed
@mattrbeck

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Named characters references containing digits are not processed properly

5 participants