[wp-trac] [WordPress Trac] #57787: WP_HTML_Tag_Processor::seek() off by 1 byte when seeking bookmarks set on a closing tag

WordPress Trac noreply at wordpress.org
Wed Feb 22 16:10:57 UTC 2023


#57787: WP_HTML_Tag_Processor::seek() off by 1 byte when seeking bookmarks set on a
closing tag
--------------------------+-----------------------------------------
 Reporter:  @…            |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  6.2
Component:  Editor        |    Version:  trunk
 Severity:  normal        |   Keywords:  needs-patch gutenberg-merge
  Focuses:                |
--------------------------+-----------------------------------------
 The HTML API was introduced in #57575. The `seek()` functionality is off
 by 1 position when seeking to find bookmarks set on a closing tag.

 Setting a bookmark on a tag should set its "start" position before the
 opening "<", e.g.:

 {{{
 <div> Testing a <b>Bookmark</b>
 ----------------^
 }}}

 The current calculation assumes this is always one byte to the left from
 `$tag_name_starts_at`.

 However, in tag closers that index points to a solidus symbol "/":

 {{{
 <div> Testing a <b>Bookmark</b>
 ----------------------------^
 }}}

 The bookmark should therefore start two bytes before the tag name:

 {{{
 <div> Testing a <b>Bookmark</b>
 ---------------------------^
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57787>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list