HTML API: Ensure correct encoding of modified class names.

Some class names with HTML character references could be mishandled, for example:
- Failure to remove an existing class like `&` with `::remove_class( '&' )`
- Double-encoding of an existing class like `&` after a modification, becoming `&`

The second case manifested after double-encoding prevention was removed from `::set_attribute()` in [60919].

Developed in https://github.com/WordPress/wordpress-develop/pull/10591.

Props jonsurrell, dmsnell.
Fixes #64340.

Built from https://develop.svn.wordpress.org/trunk@61346


git-svn-id: http://core.svn.wordpress.org/trunk@60658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
jonsurrell 2025-12-03 17:27:31 +00:00
parent 5503765994
commit 9d0d7c1b18
2 changed files with 7 additions and 5 deletions

View File

@ -2342,10 +2342,12 @@ class WP_HTML_Tag_Processor {
}
if ( false === $existing_class && isset( $this->attributes['class'] ) ) {
$existing_class = substr(
$this->html,
$this->attributes['class']->value_starts_at,
$this->attributes['class']->value_length
$existing_class = WP_HTML_Decoder::decode_attribute(
substr(
$this->html,
$this->attributes['class']->value_starts_at,
$this->attributes['class']->value_length
)
);
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-alpha-61342';
$wp_version = '7.0-alpha-61346';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.