diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php
index 88487fb068d11..73dd7d7c66868 100644
--- a/src/wp-includes/html-api/class-wp-html-tag-processor.php
+++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php
@@ -4161,6 +4161,15 @@ static function ( $tag_match ) {
case 'TEXTAREA':
case 'TITLE':
+ $plaintext_content = strtr(
+ $plaintext_content,
+ array(
+ '<' => '<',
+ '&' => '&',
+ '>' => '>',
+ )
+ );
+
$plaintext_content = preg_replace_callback(
"~(?P{$this->get_tag()})~i",
static function ( $tag_match ) {
diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
index 589318daf3a70..6f04ec4f07086 100644
--- a/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
+++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
@@ -414,9 +414,10 @@ public function test_updates_basic_modifiable_text_on_supported_nodes( string $h
'Should have modified the text at the target node.'
);
- $this->assertSame(
+ $this->assertEqualHTML(
$transformed,
$processor->get_updated_html(),
+ '',
"Should have transformed the HTML as expected when modifying the target node's modifiable text."
);
}