Html api: Fix setting attribute multiple times#4337
Closed
dmsnell wants to merge 4 commits intoWordPress:trunkfrom
Closed
Html api: Fix setting attribute multiple times#4337dmsnell wants to merge 4 commits intoWordPress:trunkfrom
dmsnell wants to merge 4 commits intoWordPress:trunkfrom
Conversation
When setting a new value for an attribute multiple times and providing multiple case variations of the attribute name the Tag Processor has been appending multiple copies of the attribute into the updated HTML. This means that only the first attribute set determines the value in the final output. In this patch we're adding a test to catch the situation.
Contributor
|
Great fix and great catch! |
ockham
reviewed
Apr 18, 2023
| */ | ||
| $existing_attribute = $this->attributes[ $comparable_name ]; | ||
| $this->lexical_updates[ $name ] = new WP_HTML_Text_Replacement( | ||
| $this->lexical_updates[ $comparable_name ] = new WP_HTML_Text_Replacement( |
Contributor
There was a problem hiding this comment.
Indentation of = signs seems no longer aligned with respect to the previous line. Kinda surprised our WPCS CI job didn't flag this 🤔
Member
Author
There was a problem hiding this comment.
I just pushed out c21f8fa which adjusts the alignment and I'm curious. so far, when things look wrong but they pass the linter it's because the linter prefers the less-legible format 😆
c21f8fa to
72ab357
Compare
Contributor
|
Committed to Core |
Contributor
|
Backported to Core's |
dmsnell
added a commit
to WordPress/gutenberg
that referenced
this pull request
Apr 20, 2023
- Support a few extra invalid comment syntaxes. WordPress/wordpress-develop#4256 - Invalidate bookmarks which have been eliminated by enqueued changes. WordPress/wordpress-develop#4116 - Expose whether the currently-matched tag has the self-closing flag. WordPress/wordpress-develop#4266 - Avoid double-writing an attribute value if given case-variations of the name. WordPress/wordpress-develop#4337
dmsnell
added a commit
to WordPress/gutenberg
that referenced
this pull request
Apr 21, 2023
- Support a few extra invalid comment syntaxes. WordPress/wordpress-develop#4256 - Invalidate bookmarks which have been eliminated by enqueued changes. WordPress/wordpress-develop#4116 - Expose whether the currently-matched tag has the self-closing flag. WordPress/wordpress-develop#4266 - Avoid double-writing an attribute value if given case-variations of the name. WordPress/wordpress-develop#4337 - Linting updates from WordPress/wordpress-develop#4360.
dmsnell
added a commit
to WordPress/gutenberg
that referenced
this pull request
Apr 24, 2023
- Support a few extra invalid comment syntaxes. WordPress/wordpress-develop#4256 - Invalidate bookmarks which have been eliminated by enqueued changes. WordPress/wordpress-develop#4116 - Expose whether the currently-matched tag has the self-closing flag. WordPress/wordpress-develop#4266 - Avoid double-writing an attribute value if given case-variations of the name. WordPress/wordpress-develop#4337 - Linting updates from WordPress/wordpress-develop#4360. - Avoid losing previous updates in certain cases when seeking earlier in a document. WordPress/wordpress-develop#4345
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.
HTML API: Ensure attribute updates happen only once for case variants
Trac ticket: #58146-trac
When setting a new value for an attribute multiple times and providing
multiple case variations of the attribute name the Tag Processor has
been appending multiple copies of the attribute into the updated HTML.
This means that only the first attribute set determines the value in
the final output.
In this patch we're adding a test to catch the situation, and then fixing
the bug by using the comparable name to key the attribute updates instead
of the case-sensitive name.