Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 5 months ago

#58146 closed defect (bug) (fixed)

HTML API: Ensure attribute updates happen only once for case variants

Reported by: dmsnell's profile dmsnell Owned by: bernhard-reiter's profile Bernhard Reiter
Milestone: 6.2.1 Priority: normal
Severity: normal Version: 6.2
Component: HTML API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Github PR: #4337

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, plus the output will appear wrong.

In this patch we're adding a test to catch the situation and resolving it
by using the appropriate comparable attribute name as a key for storing
the updates as we go. Previously we stored updates to the attribute by
its given $name, but when a new update of the same name with a
case variant was queued, it would not override the previously-enqueued
value as it out to have.

This bug has not been reported or known to be exposed.
Reproduce in trunk by enqueuing multiple updates to a given
attribute with different case variants while visiting a single tag
with the Tag Processor. (See included unit tests).

Change History (10)

This ticket was mentioned in PR #4337 on WordPress/wordpress-develop by @dmsnell.


12 months ago
#1

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.

@zieladam commented on PR #4337:


12 months ago
#2

Great fix and great catch!

#3 @Bernhard Reiter
12 months ago

  • Milestone changed from Awaiting Review to 6.2.1

#4 @Bernhard Reiter
12 months ago

  • Owner set to Bernhard Reiter
  • Resolution set to fixed
  • Status changed from new to closed

In 55659:

HTML API: Ensure attribute updates happen only once for case variants.

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, plus the output will appear wrong.

In this patch we're adding a test to catch the situation and resolving it
by using the appropriate comparable attribute name as a key for storing
the updates as we go. Previously we stored updates to the attribute by
its given $name, but when a new update of the same name with a
case variant was queued, it would not override the previously-enqueued
value as it out to have.

Props dmsnell, zieladam.
Fixes #58146.

@Bernhard Reiter commented on PR #4337:


12 months ago
#5

Committed to Core trunk in `r55659`.

#6 @Bernhard Reiter
12 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 6.2.1 consideration.

#7 @Bernhard Reiter
12 months ago

  • Keywords fixed-major added

#8 @Bernhard Reiter
12 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 55662:

HTML API: Ensure attribute updates happen only once for case variants.

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, plus the output will appear wrong.

In this patch we're adding a test to catch the situation and resolving it
by using the appropriate comparable attribute name as a key for storing
the updates as we go. Previously we stored updates to the attribute by
its given $name, but when a new update of the same name with a
case variant was queued, it would not override the previously-enqueued
value as it out to have.

Props dmsnell, zieladam.
Merges [55659] to the 6.2 branch.
Fixes #58146.

@Bernhard Reiter commented on PR #4337:


12 months ago
#9

Backported to Core's 6.2 branch in `r55662`.

#10 @Bernhard Reiter
12 months ago

  • Keywords fixed-major removed
Note: See TracTickets for help on using tickets.