Skip to content

fix: resolve foreign content namespace the way a parser re-reads it - #51

Open
dkautomation23 wants to merge 2 commits into
angular:mainfrom
dkautomation23:fix/foreign-content-namespace
Open

dkautomation23 wants to merge 2 commits into
angular:mainfrom
dkautomation23:fix/foreign-content-namespace

Conversation

@dkautomation23

Copy link
Copy Markdown

Builds on #33 (its commit is included unchanged; only the last commit is new). Happy to rebase once #33 lands.

Details are in the commit message and in the new tests in test/xss.js. Full suite: 2,241 passing locally.

SkyZeroZx and others added 2 commits September 22, 2026 22:00
Decide whether raw-text content is emitted raw or escaped from the namespace
a parser would assign when re-reading the serialized output, walking the
ancestor chain top-down:

- HTML integration points apply only inside their own namespace
  (desc/title/foreignObject in SVG; mi/mo/mn/ms/mtext and annotation-xml
  with an HTML encoding in MathML).
- Start tags that break out of foreign content (div, p, span, table, font
  with color/face/size, ...) switch back to HTML.
- The element's own closing tag is always escaped, since a breakout tag
  earlier in the same foreign container can return the parser to HTML.

The cache stores each element's own namespace and stops at the first cached
ancestor, so serialization cost stays in line with main.

Builds on angular#33.
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.

2 participants