Skip to content

fix: escape fallback raw-content ancestor tags in templates and processing instructions - #39

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix/fallback-raw-content-template-pi
Aug 20, 2026
Merged

fix: escape fallback raw-content ancestor tags in templates and processing instructions#39
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix/fallback-raw-content-template-pi

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Aug 20, 2026

Copy link
Copy Markdown

Escape ancestor fallback raw-content element closing tags (e.g., </noscript>) when serializing ProcessingInstruction nodes and when traversing DocumentFragment boundaries in <template> element content.

  1. <template> DocumentFragment Boundary (GHSA-v3p8-whq6-r5jg):

    • A <template> element stores its children in a separate DocumentFragment (template.content, nodeType === 11). Because fallbackRawContentTags(node) previously only traversed nodeType === 1 elements, ancestor walks terminated at the fragment boundary without discovering enclosing fallback raw-content ancestors (such as <noscript> or <iframe>).
    • We attach a _host reference from the <template> element's _contentFragment back to the host <template> element (and preserve this across deep cloning via cloneNode).
    • fallbackRawContentTags(node) is updated to traverse from a DocumentFragment node to its _host, enabling discovery of fallback raw-content ancestors across template boundaries.
  2. ProcessingInstruction Nodes (Incomplete fix for #70050 / #70055: </noscript> breakout still reachable through processing instructions angular#70146):

    • serializeOne() (case 7: //PROCESSING_INSTRUCTION_NODE) previously only escaped > via escapeProcessingInstructionContent(), without checking for matching fallback raw-content closing tags.
    • We mirror the comment node (case 8) logic: when PI data contains </, we check fallbackRawContentTags(parent) and escape matching closing tags (e.g., </noscript -> &lt;/noscript).

Fixes angular/angular#70146

…ssing instructions

Escape ancestor fallback raw-content element closing tags (e.g., </noscript>) when serializing ProcessingInstruction nodes, and when traversing DocumentFragment boundaries in <template> element content.

- Updates HTMLTemplateElement to attach a _host reference to its content DocumentFragment, enabling fallbackRawContentTags() to continue ancestor traversal across <template> boundaries.

- Escapes matching fallback raw-content ancestor tags in ProcessingInstruction data during HTML serialization (case 7 of serializeOne), matching the behavior of comment nodes.

Addresses:

- GHSA-v3p8-whq6-r5jg

- angular/angular#70146
@alan-agius4
alan-agius4 requested a review from JeanMeche August 20, 2026 08:07
@alan-agius4
alan-agius4 merged commit 04f987d into angular:main Aug 20, 2026
8 checks passed
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.

Incomplete fix for #70050 / #70055: </noscript> breakout still reachable through processing instructions

2 participants