Skip to content

Commit 00600da

Browse files
committed
Merge PR #43: HTML API: Preserve XMP rawtext serialization
2 parents 6b8d48c + 5736702 commit 00600da

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,7 @@ public function serialize_token(): string {
15931593

15941594
case 'SCRIPT':
15951595
case 'STYLE':
1596+
case 'XMP':
15961597
break;
15971598

15981599
default:

tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,19 @@ public function test_style_contents_are_not_escaped() {
257257
);
258258
}
259259

260+
/**
261+
* Ensures that XMP contents are not escaped, as they are not parsed like text nodes are.
262+
*
263+
* @ticket 62036
264+
*/
265+
public function test_xmp_contents_are_not_escaped() {
266+
$this->assertSame(
267+
WP_HTML_Processor::normalize( "<xmp>apples > or\x00anges & pears < plums</xmp>" ),
268+
"<xmp>apples > or\u{FFFD}anges & pears < plums</xmp>",
269+
'Should have preserved text inside an XMP element, except for replacing NULL bytes.'
270+
);
271+
}
272+
260273
public function test_unexpected_closing_tags_are_removed() {
261274
$this->assertSame(
262275
WP_HTML_Processor::normalize( 'one</div>two</span>three' ),
@@ -616,6 +629,7 @@ public static function data_provider_normalized_fuzzer_cases_that_should_be_idem
616629
'FORM with SVG TITLE text edge' => array( "<form ><svg ><title \"'></form><form>" ),
617630
'FORM with TABLE and SCRIPT' => array( '<form id><table te"><script></script><td srce" ID/></form><form claslicate">' ),
618631
'FORM with TABLE CAPTION' => array( '<form><table><caption></form><form >' ),
632+
'XMP rawtext with entity-looking text' => array( '<xmp>apples > oranges &amp; <</xmp>' ),
619633
'Short malformed G attribute C' => array( '<g c/=>' ),
620634
'Short malformed G attribute S' => array( '<g s/=>' ),
621635
'Duplicate SRC boundary' => array( '<g src=""g src="">' ),

0 commit comments

Comments
 (0)