Skip to content

Commit 1435b6e

Browse files
committed
Update escaping function to use simple strtr()
1 parent 40cfce5 commit 1435b6e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,16 @@ public function set_modifiable_text( string $plaintext_content ): bool {
37573757
$this->lexical_updates['modifiable text'] = new WP_HTML_Text_Replacement(
37583758
$this->text_starts_at,
37593759
$this->text_length,
3760-
htmlspecialchars( $plaintext_content, ENT_QUOTES | ENT_HTML5 )
3760+
strtr(
3761+
$plaintext_content,
3762+
array(
3763+
'<' => '&lt;',
3764+
'>' => '&gt;',
3765+
'&' => '&amp;',
3766+
'"' => '&quot;',
3767+
"'" => '&apos;',
3768+
)
3769+
)
37613770
);
37623771

37633772
return true;
@@ -3957,7 +3966,16 @@ public function set_attribute( $name, $value ): bool {
39573966
*/
39583967
$escaped_new_value = in_array( $comparable_name, wp_kses_uri_attributes(), true )
39593968
? esc_url( $value )
3960-
: htmlspecialchars( $value, ENT_QUOTES | ENT_HTML5 );
3969+
: strtr(
3970+
$value,
3971+
array(
3972+
'<' => '&lt;',
3973+
'>' => '&gt;',
3974+
'&' => '&amp;',
3975+
'"' => '&quot;',
3976+
"'" => '&apos;',
3977+
)
3978+
);
39613979

39623980
// If the escaping functions wiped out the update, reject it and indicate it was rejected.
39633981
if ( '' === $escaped_new_value && '' !== $value ) {

0 commit comments

Comments
 (0)