Skip to content

fix: escape fallback raw-content ancestor tags across foreign content namespaces - #36

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix/noscript-foreign-content-escape
Aug 4, 2026
Merged

fix: escape fallback raw-content ancestor tags across foreign content namespaces#36
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix/noscript-foreign-content-escape

Conversation

@alan-agius4

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

Copy link
Copy Markdown

Escape ancestor fallback raw-content element closing tags (e.g., </noscript>) when nested inside SVG or MathML foreign content elements (e.g., <foreignObject>, <svg>, <math>, <mtext>).

Previously, fallbackRawContentTags() in lib/NodeUtils.js stopped traversing ancestors when it encountered an element outside the HTML namespace (node.namespaceURI === NAMESPACE.HTML). When a fallback raw-content element like <noscript>, <iframe>, <noembed>, or <noframes> contained SVG or MathML foreign content, fallbackRawContentTags() returned an empty array, causing matching closing tags inside comments and non-fallback raw-text elements (<xmp>, <style>, etc.) to be emitted unescaped.

Solution

  • Continue ancestor traversal upwards through foreign content elements (while (node?.nodeType === 1 /*ELEMENT_NODE*/)).
  • Apply the HTML namespace check per node (if (node.namespaceURI === NAMESPACE.HTML && hasRawContentFallback[node.tagName])).
  • Added comprehensive regression and XSS breakout test cases in test/xss.js covering foreign content (svg > foreignObject and math > mtext) across all fallback raw-content tags.

Closes angular/angular#70055

@alan-agius4
alan-agius4 requested a review from JeanMeche August 3, 2026 13:06
@alan-agius4
alan-agius4 force-pushed the fix/noscript-foreign-content-escape branch from a8cd644 to 86aad57 Compare August 3, 2026 13:08
@alan-agius4
alan-agius4 requested review from JeanMeche and removed request for JeanMeche August 4, 2026 05:46
Comment thread test/xss.js Outdated
… namespaces

Escape ancestor fallback raw-content element closing tags (e.g., </noscript>)
when nested inside SVG or MathML foreign content elements (e.g., <foreignObject>,
<svg>, <math>, <mtext>).

Previously, fallbackRawContentTags() stopped traversing ancestors when it encountered
an element outside the HTML namespace, causing it to miss enclosing fallback
raw-content tags and leave their closing tags unescaped.

Closes angular/angular#70055
@alan-agius4
alan-agius4 force-pushed the fix/noscript-foreign-content-escape branch from 86aad57 to 5d2158c Compare August 4, 2026 08:17
@alan-agius4
alan-agius4 merged commit e0779df into angular:main Aug 4, 2026
8 checks passed
@alan-agius4
alan-agius4 deleted the fix/noscript-foreign-content-escape branch August 4, 2026 08:18
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: </noscript> breakout still reachable through SVG/MathML foreign content

2 participants