File tree Expand file tree Collapse file tree
tests/phpunit/tests/html-api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1498,6 +1498,7 @@ public function serialize_token(): string {
14981498
14991499 case 'SCRIPT ' :
15001500 case 'STYLE ' :
1501+ case 'XMP ' :
15011502 break ;
15021503
15031504 default :
Original file line number Diff line number Diff line change @@ -134,6 +134,26 @@ public function test_style_contents_are_not_escaped() {
134134 );
135135 }
136136
137+ /**
138+ * Ensures that XMP contents are not escaped, as they are not parsed like text nodes are.
139+ *
140+ * @ticket 65372
141+ */
142+ public function test_xmp_contents_are_not_escaped () {
143+ $ normalized = WP_HTML_Processor::normalize ( "<xmp>apples > or \x00anges & carrots</xmp> " );
144+
145+ $ this ->assertSame (
146+ "<xmp>apples > or \u{FFFD}anges & carrots</xmp> " ,
147+ $ normalized ,
148+ 'Should have preserved text inside an XMP element, except for replacing NULL bytes. '
149+ );
150+ $ this ->assertSame (
151+ $ normalized ,
152+ WP_HTML_Processor::normalize ( $ normalized ),
153+ 'Normalizing already-normalized XMP should not escape the raw text again. '
154+ );
155+ }
156+
137157 public function test_unexpected_closing_tags_are_removed () {
138158 $ this ->assertSame (
139159 WP_HTML_Processor::normalize ( 'one</div>two</span>three ' ),
You can’t perform that action at this time.
0 commit comments