HTML API: Ensure form feed is recognized as close tag name terminator - #12936
HTML API: Ensure form feed is recognized as close tag name terminator#12936sirreal wants to merge 6 commits into
Conversation
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.
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
westonruter
left a comment
There was a problem hiding this comment.
LGTM. Nit suggestions for narrower types.
| * | ||
| * @return Generator<string, array{string}> Test cases. | ||
| */ | ||
| public static function data_tag_name_terminators(): Generator { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| * @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. |
There was a problem hiding this comment.
| * @return Generator<string, array{string, string}> Test cases. | |
| * @return Generator<non-falsy-string, array{non-falsy-string, non-falsy-string}> Test cases. |
| * @param string $tag_name The RCDATA or RAWTEXT tag name. | ||
| * @param string $tag_name_terminator The tag-name-terminating character. |
There was a problem hiding this comment.
| * @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. |
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 throughskip_rcdata()andskip_rawtext(). The Cartesian provider keeps all 49 cases independent and leaves the terminator provider reusable.SCRIPTuses 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-apiWP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit --group=html-api-web-platform-testsvendor/bin/phpcs --standard=phpcs.xml.dist src/wp-includes/html-api/class-wp-html-tag-processor.php tests/phpunit/tests/html-api/wpHtmlTagProcessor.phpgit diff --checkpass.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.