Commit af67d0c658 for wordpress.org
commit af67d0c6581b9d756c373b9e69d26b0c0c466ca6
Author: dmsnell <dmsnell@git.wordpress.org>
Date: Tue Jan 20 21:05:35 2026 +0000
KSES: Early-abort in wp_kses_hair() when no attributes exist.
When `wp_kses_hair()` calls into the HTML API to parse an attribute string, it checks if the result might be `null` and returns early, skipping a few minor operations. It could also skip when the returned attribute count is zero.
This patch adds the additional check and early-return.
Developed in: https://github.com/WordPress/wordpress-develop/pull/10764
Discussed in: https://core.trac.wordpress.org/ticket/63724
Follow-up to [61499].
Props dd32, dmsnell, jonsurrell.
See #63724.
Built from https://develop.svn.wordpress.org/trunk@61503
git-svn-id: http://core.svn.wordpress.org/trunk@60814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/kses.php b/wp-includes/kses.php
index 872034621f..c71453177d 100644
--- a/wp-includes/kses.php
+++ b/wp-includes/kses.php
@@ -1624,7 +1624,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
$processor->next_token();
$attribute_names = $processor->get_attribute_names_with_prefix( '' );
- if ( ! isset( $attribute_names ) ) {
+ if ( null === $attribute_names || 0 === count( $attribute_names ) ) {
return $attributes;
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 4ff626c7e7..09ff0899dc 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61502';
+$wp_version = '7.0-alpha-61503';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.