[wp-trac] [WordPress Trac] #60382: HTML API: WP_HTML_Processor::next_token nests void tags
WordPress Trac
noreply at wordpress.org
Thu Feb 1 00:41:55 UTC 2024
#60382: HTML API: WP_HTML_Processor::next_token nests void tags
--------------------------------------+------------------------------
Reporter: jonsurrell | Owner: jonsurrell
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: HTML API | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Changes (by dmsnell):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"57507" 57507]:
{{{
#!CommitTicketReference repository="" revision="57507"
HTML API: Fix void tag nesting with next_token
When `next_token()` was introduced, it introduced a regression in the HTML
Processor whereby void tags remain on the stack of open elements when they
shouldn't. This led to invalid values returned from `get_breadcrumbs()`.
The reason was that calling `next_token()` works through a different code
path
than the HTML Processor runs everything else. To solve this, its sub-
classed
`next_token()` called `step( self::REPROCESS_CURRENT_TOKEN )` so that the
proper
HTML accounting takes place.
Unfortunately that same reprocessing code path skipped the step whereby
void
and self-closing elements are popped from the stack of open elements.
In this patch, that step is run with a third mode for `step()`, which is
the
new `self::PROCESS_CURRENT_TOKEN`. This mode acts as if
`self::PROCESS_NEXT_NODE`
were called, except it doesn't advance the parser.
Developed in https://github.com/WordPress/wordpress-develop/pull/5975
Discussed in https://core.trac.wordpress.org/ticket/60382
Follow-up to [57348]
Props dmsnell, jonsurrell
Fixes #60382
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60382#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list