Skip to content

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Jul 13, 2025

See #9248

This branch is collecting all of the various changes necessary to refactor wp_kses_hair() to use the HTML API. It’s mainly for running tests and determining which tests are currently broken and need to be updated to prevent false negatives.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@dmsnell dmsnell force-pushed the wp-kses-hair-fixes branch 5 times, most recently from c5909df to d18919f Compare July 14, 2025 17:07
Trac ticket: Core-63694

`wp_kses_hair()` is built around an impressive state machine for parsing
the `$attr` of an HTML tag, that is, the span of text after the tag name
and before the closing `>`. Unfortunately, that parsing code doesn’t
fully-implement the HTML specification and may be prone to mis-parsing.

This patch replaces the existing state machine with a straight-forward
use of the HTML API to parse the attributes for us, constructing a shell
take for the `$attr` string and reading the attributes structurally.
This shell is necessary because a previous stage of the pipeline has
already separated what it thinks is the so-called “attribute list” from
a tag.

Props: dmsnell
@dmsnell dmsnell force-pushed the wp-kses-hair-fixes branch 7 times, most recently from bf51620 to cdcc474 Compare July 15, 2025 03:31
@dmsnell dmsnell force-pushed the wp-kses-hair-fixes branch 3 times, most recently from 479a8f9 to 5c44635 Compare July 15, 2025 16:11
@dmsnell dmsnell force-pushed the wp-kses-hair-fixes branch 3 times, most recently from 3f0c2d7 to 91dd319 Compare July 18, 2025 21:00
@dmsnell dmsnell force-pushed the wp-kses-hair-fixes branch from 91dd319 to c297fb0 Compare July 18, 2025 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant