Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#60687 closed defect (bug) (fixed)

HTML API: Ensure that breadcrumbs are properly retained after seeking.

Reported by: dmsnell's profile dmsnell Owned by: dmsnell's profile dmsnell
Milestone: 6.5 Priority: normal
Severity: normal Version: 6.5
Component: HTML API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

In some cases, it's possible to seek back into a location found inside an element which has been completely closed before the seek. In these cases the breadcrumb stack is lost, and calling get_breadcrumbs() after the seek will return the wrong information.

This patch changes the seek() behavior to rewind to the start of the document and re-parse everything up until the sought-after bookmark location. This is a drastic choice but maintains the accuracy of the breadcrumbs. While slow, this can be later optimized in a way that preserves the parser state.

Change History (3)

This ticket was mentioned in PR #6185 on WordPress/wordpress-develop by @dmsnell.


12 months ago
#1

Trac ticket: Core-60687

In some cases, it's possible to seek back into a location found inside an element which has been completely closed before the seek. In these cases the breadcrumb stack is lost, and calling get_breadcrumbs() after the seek will return the wrong information.

This patch changes the seek() behavior to rewind to the start of the document and re-parse everything up until the sought-after bookmark location. This is a drastic choice but maintains the accuracy of the breadcrumbs. While slow, this can be later optimized in a way that preserves the parser state.

#2 @dmsnell
12 months ago

  • Owner set to dmsnell
  • Resolution set to fixed
  • Status changed from new to closed

In 57768:

HTML API: Ensure that breadcrumbs are properly retained after seeking.

In some cases, it's possible to seek back into a location found inside
an element which has been closed before the point in the document where
the seek() was made. In these cases the breadcrumb stack is lost, and
calling get_breadcrumbs() after the seek will return the wrong information.

In this patch, the HTML Processor takes a conservative approach and
moves to the front of the document, then reparses the document until
it reaches the sought-after location. This ensures consistency on
the stack of open elements and active formats, and preserves
breadcrumbs.

Developed in https://github.com/WordPress/wordpress-develop/pull/6185
Discussed in https://core.trac.wordpress.org/ticket/60687

Props jonsurrell.
Follow-up to [60687].
See #58517.
Fixes #60687.

Note: See TracTickets for help on using tickets.