Skip to content

Commit d0d323a

Browse files
committed
Handle normalization when attributes starting with = follow boolean attributes
1 parent 67fc00b commit d0d323a

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,15 +1414,28 @@ public function serialize_token(): string {
14141414
}
14151415

14161416
$html .= "<{$qualified_name}";
1417+
1418+
$previous_attribute_was_true = false;
14171419
foreach ( $attribute_names as $attribute_name ) {
1418-
$html .= " {$this->get_qualified_attribute_name( $attribute_name )}";
1420+
$qualified_attribute_name = $this->get_qualified_attribute_name( $attribute_name );
1421+
1422+
if (
1423+
$previous_attribute_was_true &&
1424+
isset( $qualified_attribute_name[0] ) &&
1425+
'=' === $qualified_attribute_name[0]
1426+
) {
1427+
$html .= '=""';
1428+
}
1429+
1430+
$html .= " {$qualified_attribute_name}";
14191431
$value = $this->get_attribute( $attribute_name );
14201432

14211433
if ( is_string( $value ) ) {
14221434
$html .= '="' . htmlspecialchars( $value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5 ) . '"';
14231435
}
14241436

1425-
$html = str_replace( "\x00", "\u{FFFD}", $html );
1437+
$previous_attribute_was_true = true === $value;
1438+
$html = str_replace( "\x00", "\u{FFFD}", $html );
14261439
}
14271440

14281441
if ( ! $in_html && $this->has_self_closing_flag() ) {

0 commit comments

Comments
 (0)