[wp-trac] [WordPress Trac] #63724: HTML API: Reliably parse HTML attributes in `wp_kses_hair()`
WordPress Trac
noreply at wordpress.org
Mon Jan 19 20:44:55 UTC 2026
#63724: HTML API: Reliably parse HTML attributes in `wp_kses_hair()`
-------------------------------------------------+-------------------------
Reporter: dmsnell | Owner: dmsnell
Type: enhancement | Status: reopened
Priority: normal | Milestone: 7.0
Component: HTML API | Version: 6.9
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
refresh |
-------------------------------------------------+-------------------------
Comment (by dmsnell):
In [changeset:"61499" 61499]:
{{{
#!CommitTicketReference repository="" revision="61499"
HTML API: Fix missing null-check in wp_kses_hair() refactor.
When no attributes are present, `wp_kses_hair()` should return an empty
array, but when the refactor was merged, the code assumed there would be
attributes.
An alternative fix is to use null-coalescing to iterate over an empty
array. This would produce a marginally smaller function and read
slightly more cleanly, but there’s no need to enter the `foreach` loop
when it’s known in advance that there’s nothing over which to iterate.
Developed in: https://github.com/WordPress/wordpress-develop/pull/10758
Discussed in: https://core.trac.wordpress.org/ticket/63724
Follow-up to [61467].
Props: dd32, dmsnell, jonsurrell.
See: #63724.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63724#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list