Skip to content

Commit c28d7b0

Browse files
committed
Prevent printing duplicate attributes after normalizing the attribute names.
1 parent 0c70c69 commit c28d7b0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,8 +1417,16 @@ public function serialize_token(): string {
14171417
$html .= "<{$qualified_name}";
14181418

14191419
$previous_attribute_was_true = false;
1420+
$seen_attribute_names = array();
14201421
foreach ( $attribute_names as $attribute_name ) {
14211422
$qualified_attribute_name = $this->get_qualified_attribute_name( $attribute_name );
1423+
$qualified_attribute_name = str_replace( "\x00", "\u{FFFD}", $qualified_attribute_name );
1424+
$qualified_attribute_name = wp_scrub_utf8( $qualified_attribute_name );
1425+
if ( isset( $seen_attribute_names[ $qualified_attribute_name ] ) ) {
1426+
continue;
1427+
} else {
1428+
$seen_attribute_names[ $qualified_attribute_name ] = true;
1429+
}
14221430

14231431
if (
14241432
$previous_attribute_was_true &&

0 commit comments

Comments
 (0)