-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Html api: Fix setting attribute multiple times #4337
Html api: Fix setting attribute multiple times #4337
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.
Great fix and great catch! |
@@ -1908,7 +1909,7 @@ public function set_attribute( $name, $value ) { | |||
* Result: <div id="new"/> | |||
*/ | |||
$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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation of =
signs seems no longer aligned with respect to the previous line. Kinda surprised our WPCS CI job didn't flag this 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Committed to Core |
Backported to Core's |
- 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
- 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.
- 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
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.