#62241 closed defect (bug) (fixed)
HTML API: Fix the position update after changing the modifiable text when length differs
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | 6.7 |
Component: | HTML API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Reported by @zieladam on GitHub: https://github.com/WordPress/wordpress-develop/pull/7007#issuecomment-2412540433
I just isolated the problem:
$p = new WP_HTML_Tag_Processor('Hello there'); $p->next_token(); $p->set_modifiable_text('Short'); echo $p->get_updated_html();
It's not occurring with this patch:
- $this->bytes_already_parsed = $before_current_tag; + if ($this->get_token_type() === '#tag') { + $this->bytes_already_parsed = $before_current_tag; + }
The actual fix will be more nuanced because the text node might appear in the HTML in the middle or at the end of the HTML provided, examples:
<p>Hello</p>String to replace
<p>Hello</p>String to replace<p>Hello</p>
Change History (6)
This ticket was mentioned in PR #7577 on WordPress/wordpress-develop by @gziolo.
9 months ago
#1
- Keywords has-patch has-unit-tests added
@jonsurrell commented on PR #7577:
9 months ago
#2
@gziolo I've proposed a fix for this in https://github.com/gziolo/wordpress-develop/pull/2 that can be merged into this PR.
#4
@
9 months ago
- Owner set to gziolo
- Resolution set to fixed
- Status changed from new to closed
In 59250:
9 months ago
#5
Committed with https://core.trac.wordpress.org/changeset/59250.
@zieladam commented on PR #7577:
9 months ago
#6
Thank you so much for a timely fix!
Note: See
TracTickets for help on using
tickets.
Reported by @adamziel in https://github.com/WordPress/wordpress-develop/pull/7007#issuecomment-2412540433:
Trac ticket: https://core.trac.wordpress.org/ticket/62241