Skip to content

HTML API: Ensure form feed is recognized as close tag name terminator - #12936

Open
sirreal wants to merge 6 commits into
WordPress:trunkfrom
sirreal:html-api-rawtext-ff
Open

HTML API: Ensure form feed is recognized as close tag name terminator#12936
sirreal wants to merge 6 commits into
WordPress:trunkfrom
sirreal:html-api-rawtext-ff

Conversation

@sirreal

@sirreal sirreal commented Aug 7, 2026

Copy link
Copy Markdown
Member

WP_HTML_Tag_Processor::skip_rcdata() omits U+000C FORM FEED from the end-tag-name terminator set. A valid closer such as </xmp\f> is treated as text, and the processor reports the complete XMP element as incomplete. The same broken scanner handles six other RCDATA and RAWTEXT elements.

Add FORM FEED to the predicate. Test the complete terminator contract — space, tab, LF, FF, CR, /, and > — against every element routed through skip_rcdata() and skip_rawtext(). The Cartesian provider keeps all 49 cases independent and leaves the terminator provider reusable. SCRIPT uses a separate scanner that already handles the full set.

Trac ticket: https://core.trac.wordpress.org/ticket/65372

Testing

  • WP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group html-api
    • 1,714 tests, 6,107 assertions, 1 skipped.
  • WP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group=html-api-web-platform-tests
    • 1,707 tests, 1,261 assertions, 446 skipped.
  • vendor/bin/phpcs --standard=phpcs.xml.dist src/wp-includes/html-api/class-wp-html-tag-processor.php tests/phpunit/tests/html-api/wpHtmlTagProcessor.php
  • PHP syntax and git diff --check pass.

Use of AI Tools

AI assistance: Yes
Tool(s): OpenAI Codex
Model(s): GPT-5
Used for: Reproducing the defect, auditing related tokenizer paths, implementing the fix and tests, adversarial review, and drafting this description. The contributor reviewed the final changes and test results.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

sirreal added 4 commits August 7, 2026 15:47
Form feed is ASCII whitespace. It terminates an appropriate RCDATA or RAWTEXT end tag name, but skip_rcdata() rejects it and leaves the entire special element incomplete.

Cover every element routed through that scanner. SCRIPT uses a separate scanner and already has this coverage.
skip_rcdata() omits form feed from the tag-name terminator set even though it is ASCII whitespace. Valid RCDATA and RAWTEXT closers then look like text, so the processor pauses on a complete element.

Accept form feed before handing the closer to the existing attribute scanner.
The test and provider leave their return contracts partly implicit. State void and the exact generator key and value shape so static analysis does not have to guess.
The regression test names only form feed, but skip_rcdata() implements a seven-character boundary contract. Testing one byte leaves the other accepted paths free to drift.

Keep the terminators in a reusable provider and run the full Cartesian matrix as independent cases.
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

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

  • 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.

@sirreal
sirreal marked this pull request as ready for review August 10, 2026 09:02
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal
sirreal requested review from dmsnell and westonruter August 10, 2026 11:18

@westonruter westonruter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nit suggestions for narrower types.

*
* @return Generator<string, array{string}> Test cases.
*/
public static function data_tag_name_terminators(): Generator {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice. I didn't realize you could use a generator as a data provider.

/**
* Provides tag-name-terminating characters.
*
* @return Generator<string, array{string}> Test cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return Generator<string, array{string}> Test cases.
* @return Generator<non-falsy-string, array{non-falsy-string}> Test cases.

/**
* Provides every RCDATA and RAWTEXT tag with every tag-name-terminating character.
*
* @return Generator<string, array{string, string}> Test cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return Generator<string, array{string, string}> Test cases.
* @return Generator<non-falsy-string, array{non-falsy-string, non-falsy-string}> Test cases.

Comment on lines +2379 to +2380
* @param string $tag_name The RCDATA or RAWTEXT tag name.
* @param string $tag_name_terminator The tag-name-terminating character.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param string $tag_name The RCDATA or RAWTEXT tag name.
* @param string $tag_name_terminator The tag-name-terminating character.
* @param non-falsy-string $tag_name The RCDATA or RAWTEXT tag name.
* @param non-falsy-string $tag_name_terminator The tag-name-terminating character.

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.

2 participants