From ec9cc1acd76c409c3889dc0b02357964ae0073f9 Mon Sep 17 00:00:00 2001
From: SkyZeroZx <73321943+SkyZeroZx@users.noreply.github.com>
Date: Sat, 23 May 2026 16:58:27 -0500
Subject: [PATCH 1/2] fix: Escapes `` elements is properly escaped during serialization if scripting is enabled.
Adds a test to verify controlled payloads cannot break out of `';
+ document.body.appendChild(noscript);
+
+ document.body
+ .serialize()
+ .should.equal('abc</noscript>');
+
+ const html = document.serialize();
+ return alertFired(html).should.eventually.be.false('alert fired for: ' + html);
+};
+
exports.scriptMatchingClosingTagInRawText = function () {
const document = domino.createDocument('');
const script = document.createElement('script');
From 3c2d125eb2d31d1a5e19e3ad7223fada0e9e0c7b Mon Sep 17 00:00:00 2001
From: SkyZeroZx <73321943+SkyZeroZx@users.noreply.github.com>
Date: Mon, 25 May 2026 15:15:41 -0500
Subject: [PATCH 2/2] fix: fix XSS in raw-text element serialization
Correct raw-text closing-tag escaping so astral Unicode characters cannot
misalign the escaped `<` character. This prevents serialized raw-text content
from breaking out into executable markup such as `";
+
+ const html = document.serialize();
+ html.should.not.match(/<\/iframe>',
],
+
+ // Astral (non-BMP) characters before the closing tag must not shift
+ // the position of the escape: regex `match.index` is a UTF-16 code-unit
+ // offset while a code-point array would be off by one per astral char.
+ [
+ '\uD83D\uDE00'.repeat(20) + '',
+ 'iframe',
+ '\uD83D\uDE00'.repeat(20) + '</iframe>',
+ ],
+ [
+ '\uD83D\uDE00',
+ 'style',
+ '\uD83D\uDE00</style>',
+ ],
];
for (const [rawContent, parentTag, expected] of cases) {
NodeUtils.ɵescapeMatchingClosingTag(rawContent, parentTag).should.equal(expected);