Optimization Detective: Handle stray closing P tags when P is not open - #2653
Closed
wprashed wants to merge 2 commits into
Closed
Optimization Detective: Handle stray closing P tags when P is not open#2653wprashed wants to merge 2 commits into
wprashed wants to merge 2 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Member
|
There is already an open PR for this: #2651 Please carefully review an issue and any associated PRs before starting your own. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2650
Description
When
wpautop()wraps multiple shortcodes (e.g.<p><figure>...</figure><figure>...</figure></p>), encountering the first<figure>causesOD_HTML_Tag_Processorto implicitly popPoff the open tag stack (sinceFIGUREis inP_CLOSING_TAGS).When the trailing
</p>tag is later encountered,Pis no longer at the top of->open_stack_tags. Previously,OD_HTML_Tag_Processorcalledarray_pop( $this->open_stack_tags ), popping a parent element (such as<div class="entry-content">) off the stack. This corrupted the open tag stack for the rest of the document, emitting warnings and producing incorrectdata-od-xpathattributes on subsequent elements.This PR updates
OD_HTML_Tag_Processorto:</p>tag is encountered whilePis not at the top of->open_stack_tags.$this->open_stack_indices[ $level ]to match browser DOM behavior (where an implied empty<p>element occupies a sibling slot).trueearly without popping parent tags or emitting false warnings.Testing Instructions
plugins/optimization-detective/class-od-html-tag-processor.phpandplugins/optimization-detective/tests/test-class-od-html-tag-processor.php.<p><figure>...</figure><figure>...</figure></p>parses without warnings and computes accurate XPath breadcrumbs for subsequent elements.