Skip to content

fix: escape fallback raw-content ancestor tags in processing instructions - #38

Closed
RubenPari wants to merge 1 commit into
angular:mainfrom
RubenPari:fix-pi-noscript-breakout
Closed

fix: escape fallback raw-content ancestor tags in processing instructions#38
RubenPari wants to merge 1 commit into
angular:mainfrom
RubenPari:fix-pi-noscript-breakout

Conversation

@RubenPari

Copy link
Copy Markdown

Summary

Fixes the remaining part of the regression reported in angular/angular#70050 / #70055, tracked as angular/angular#70146.

serializeOne()'s PROCESSING_INSTRUCTION_NODE branch (case 7) never called fallbackRawContentTags()/escapeMatchingClosingTag(), unlike the COMMENT_NODE branch (case 8) fixed in fc7e40a. escapeProcessingInstructionContent() only escapes >, so a literal </noscript (or </iframe, </noembed, </noframes) sequence in PI data passes through untouched and reaches the browser's RAWTEXT tokenizer unescaped, closing the fallback element early and exposing following sibling markup (e.g. an <img onerror>) as live DOM.

This mirrors the fix already applied to the comment-node branch, escaping the ancestor's closing tag inside PI content the same way.

Test plan

  • Added noscriptProcessingInstructionAncestorClosingTagEscaped to test/xss.js, verifying both the exact escaped serialization and that no alert fires when the resulting HTML is loaded in a real browser (puppeteer).
  • Confirmed the new test fails without the fix and passes with it.
  • npx mocha test/domino.js test/parsing.js test/readonly.js test/xss.js — all passing (excluding one pre-existing, unrelated timeout in fallbackRawTextNestedRawTextElementsEscapeAncestorClosingTag that reproduces identically without this change).

…ions

serializeOne()'s PROCESSING_INSTRUCTION_NODE branch never called
fallbackRawContentTags()/escapeMatchingClosingTag(), unlike the
COMMENT_NODE branch fixed in fc7e40a. A literal "</noscript" (or
</iframe, </noembed, </noframes) sequence in PI data survives
escapeProcessingInstructionContent() (which only escapes '>'), so it
reaches the browser's RAWTEXT tokenizer unescaped and closes the
fallback element early, exposing following sibling markup as live
DOM.

Mirrors the fix already applied to the comment-node branch.
@google-cla

google-cla Bot commented Aug 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@JeanMeche

Copy link
Copy Markdown
Member

THE CLA wasn't signed. We can't proceed with this PR.

@JeanMeche JeanMeche closed this Aug 17, 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.

2 participants