Skip to content

Commit

Permalink
Add space after attribute values.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed May 17, 2024
1 parent 5079cbc commit d47b8b2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/wp-includes/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -1343,14 +1343,16 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
return array();
}

$attribute_count = count( $parsed_attributes );
foreach ( $parsed_attributes as $attribute_name ) {
$value = $processor->get_attribute( $attribute_name );
$suffix = ( $attribute_count > 1 && ( $i < $attribute_count - 1 ) ) ? ' ' : '';
$value = $processor->get_attribute( $attribute_name );

if ( true === $value ) {
$attributes[ $attribute_name ] = array(
'name' => $attribute_name,
'value' => '',
'whole' => $attribute_name,
'whole' => "{$attribute_name}{$suffix}",
'vless' => 'y',
);
} else {
Expand All @@ -1363,7 +1365,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
$attributes[ $attribute_name ] = array(
'name' => $attribute_name,
'value' => $value,
'whole' => "{$attribute_name}=\"{$escaped_value}\"",
'whole' => "{$attribute_name}=\"{$escaped_value}\"{$suffix}",
'vless' => 'n',
);
}
Expand Down Expand Up @@ -1407,13 +1409,16 @@ function wp_kses_attr_parse( $element ) {
$parsed_attributes = array();
}

foreach ( $parsed_attributes as $attribute_name ) {
$value = $processor->get_attribute( $attribute_name );
$attribute_count = count( $parsed_attributes );
foreach ( $parsed_attributes as $i => $attribute_name ) {
$suffix = ( $attribute_count > 1 && ( $i < $attribute_count - 1 ) ) ? ' ' : '';
$value = $processor->get_attribute( $attribute_name );

if ( true === $value ) {
$chunks[] = $attribute_name;
$chunks[] = "{$attribute_name}{$suffix}";
} else {
$value = str_replace( '"', '&quot;', $value );
$chunks[] = "{$attribute_name}=\"{$value}\"";
$chunks[] = "{$attribute_name}=\"{$value}\"{$suffix}";
}
}

Expand Down

0 comments on commit d47b8b2

Please sign in to comment.