Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,7 @@ public function serialize_token(): string {

case 'SCRIPT':
case 'STYLE':
case 'XMP':
break;

default:
Expand Down
14 changes: 14 additions & 0 deletions tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ public function test_style_contents_are_not_escaped() {
);
}

/**
* Ensures that XMP contents are not escaped, as they are not parsed like text nodes are.
*
* @ticket 62036
*/
public function test_xmp_contents_are_not_escaped() {
$this->assertSame(
WP_HTML_Processor::normalize( "<xmp>apples > or\x00anges & pears < plums</xmp>" ),
"<xmp>apples > or\u{FFFD}anges & pears < plums</xmp>",
'Should have preserved text inside an XMP element, except for replacing NULL bytes.'
);
}

public function test_unexpected_closing_tags_are_removed() {
$this->assertSame(
WP_HTML_Processor::normalize( 'one</div>two</span>three' ),
Expand Down Expand Up @@ -493,6 +506,7 @@ public static function data_provider_normalized_fuzzer_cases_that_should_be_idem
'FORM with SVG TITLE text edge' => array( "<form ><svg ><title \"'></form><form>" ),
'FORM with TABLE and SCRIPT' => array( '<form id><table te"><script></script><td srce" ID/></form><form claslicate">' ),
'FORM with TABLE CAPTION' => array( '<form><table><caption></form><form >' ),
'XMP rawtext with entity-looking text' => array( '<xmp>apples > oranges &amp; <</xmp>' ),
'Short malformed G attribute C' => array( '<g c/=>' ),
'Short malformed G attribute S' => array( '<g s/=>' ),
'Duplicate SRC boundary' => array( '<g src=""g src="">' ),
Expand Down
Loading