Skip to content

Commit 686dc5e

Browse files
committed
Escape syntax characters in RCDATA
1 parent 25a91cb commit 686dc5e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,6 +4161,15 @@ static function ( $tag_match ) {
41614161

41624162
case 'TEXTAREA':
41634163
case 'TITLE':
4164+
$plaintext_content = strtr(
4165+
$plaintext_content,
4166+
array(
4167+
'<' => '&lt;',
4168+
'&' => '&amp;',
4169+
'>' => '&gt;',
4170+
)
4171+
);
4172+
41644173
$plaintext_content = preg_replace_callback(
41654174
"~</(?P<TAG_NAME>{$this->get_tag()})~i",
41664175
static function ( $tag_match ) {

tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,10 @@ public function test_updates_basic_modifiable_text_on_supported_nodes( string $h
414414
'Should have modified the text at the target node.'
415415
);
416416

417-
$this->assertSame(
417+
$this->assertEqualHTML(
418418
$transformed,
419419
$processor->get_updated_html(),
420+
'<body>',
420421
"Should have transformed the HTML as expected when modifying the target node's modifiable text."
421422
);
422423
}

0 commit comments

Comments
 (0)