[wp-trac] [WordPress Trac] #59607: HTML API: Fix - avoid calling subclass method while internally scanning in Tag Processor
WordPress Trac
noreply at wordpress.org
Mon Oct 16 14:00:17 UTC 2023
#59607: HTML API: Fix - avoid calling subclass method while internally scanning in
Tag Processor
-------------------------------------------------+-------------------------
Reporter: dmsnell | Owner:
| SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.4
Component: HTML API | Version: trunk
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests has- | Focuses:
testing-info |
-------------------------------------------------+-------------------------
Changes (by SergeyBiryukov):
* owner: (none) => SergeyBiryukov
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"56941" 56941]:
{{{
#!CommitTicketReference repository="" revision="56941"
HTML API: Avoid calling subclass method while internally scanning in Tag
Processor.
After modifying tags in the HTML API, the Tag Processor backs up to before
the tag being modified and then re-parses its attributes. This saves on
the code complexity involved in applying updates, which have already been
transformed to “lexical updates” by the time they are applied.
In order to do that, `::get_updated_html()` called `::next_tag()` to reuse
its logic. However, as a public method, subclasses may change the behavior
of that method, and the HTML Processor does just this. It maintains an
HTML stack of open elements and when the Tag Processor calls this method
to re-scan a tag and its attributes, it leads to a broken stack.
This commit replaces the call to `::next_tag()` with a more appropriate
reapplication of its internal parsing logic to rescan the tag name and its
attributes. Given the limited nature of what's occurring in
`::get_updated_html()`, this should bring with it certain guarantees that
no HTML structure is being changed (that structure will only be changed by
subclasses like the HTML Processor).
Follow-up to [56274], [56702].
Props dmsnell, zieladam, nicolefurlan.
Fixes #59607.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59607#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list