Conversation
|
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. |
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. |
When a document ends in `<`, `<!`, or `<!-` and no further `<!--` follows, `WP_Block_Processor::next_token()` reports a block delimiter which is not in the document. `next_delimiter()` returns true for it, `opens_block()` is true, and the reported name, attributes, and delimiter type repeat the previous delimiter, or the uninitialized defaults when there was no previous delimiter. The open-block stack also gains an entry which is never popped. The branch which handles a missing `<!--` emits the preceding HTML span with `matched_delimiter_at` set before the end of the document, because the trailing partial is measured into the span's length. The re-entry at the top of `next_token()` only completes when `matched_delimiter_at` reaches the end, so it promotes the HTML span to a matched delimiter instead. Record the incomplete input when the span is emitted. The guard at the top of `next_token()` then stops the promotion, and the existing reporting of `INCOMPLETE_INPUT` is preserved.
a58d436 to
cdd5542
Compare
Stop
WP_Block_Processorfrom reporting an extra block delimiter when HTML content ends in<,<!, or<!-.For example,
<!-- wp:a -->text<makesnext_delimiter()reportcore/atwice. With no previous delimiter,text<reports a delimiter with an empty block name.The processor returns the final HTML span but then treats the trailing bytes as a delimiter, reusing the previous delimiter's state. Set
INCOMPLETE_INPUTwhen returning that span so the next call stops parsing. The example then produces onecore/adelimiter and an HTML span;next_token()returns false on the following call.Ten test cases cover the three partial comment prefixes, preceding opening, void and closing delimiters, and two complete-input controls. Eight cases fail before the fix. Local validation passed: 232
block-processortests and 633blockstests.Trac ticket: https://core.trac.wordpress.org/ticket/66138
Use of AI Tools
AI assistance: Yes
Tools: Claude Code, Codex
Models: Claude Opus, GPT-6
Used for: Finding the defect, drafting the fix and tests, and editing this description.
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.