[wp-trac] [WordPress Trac] #58179: HTML API: Accumulate shift for internal parsing pointer.
WordPress Trac
noreply at wordpress.org
Wed May 3 12:09:37 UTC 2023
#58179: HTML API: Accumulate shift for internal parsing pointer.
-------------------------------------------------+-------------------------
Reporter: dmsnell | Owner: Bernhard
| Reiter
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting
| Review
Component: HTML API | Version: 6.2
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests fixed- | Focuses:
major |
-------------------------------------------------+-------------------------
Changes (by Bernhard Reiter):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"55708" 55708]:
{{{
#!CommitTicketReference repository="" revision="55708"
HTML API: Accumulate shift for internal parsing pointer.
A bug was discovered where where the parser wasn't returning to the
start of the affected tag after making some updates.
In few words, the Tag Processor has not been treating its own internal
pointer `bytes_already_parsed` the same way it treats its bookmarks.
That is, when updates are applied to the input document and then
`get_updated_html()` is called, the internal pointer transfers to
the newly-updated content as if no updates had been applied since
the previous call to `get_updated_html()`.
In this patch we're creating a new "shift accumulator" to account for
all of the updates that accrue before calling `get_updated_html()`.
This accumulated shift will be applied when swapping the input document
with the output buffer, which should result in the pointer pointing to
the same logical spot in the document it did before the udpate.
In effect this patch adds a single workaround for treating the
internal pointer like a bookmark, plus a temporary pointer which points
to the beginning of the current tag when calling `get_updated_html()`.
This will preserve the assumption that updating a document doesn't
move that pointer, or shift which tag is currently matched.
Props dmsnell, zieladam.
Merges [55706] to the 6.2 branch.
Fixes #58179.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58179#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list