Skip to content

Commit 9ad568e

Browse files
jorgefilipecostamichalczaplinski
authored andcommitted
Add: Missing output escaping on some blocks. (#45045)
1 parent 8a00f6a commit 9ad568e

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

packages/block-library/src/navigation/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
646646
$toggle_aria_label_close,
647647
esc_attr( implode( ' ', $responsive_container_classes ) ),
648648
esc_attr( implode( ' ', $open_button_classes ) ),
649-
safecss_filter_attr( $colors['overlay_inline_styles'] ),
649+
esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ),
650650
__( 'Menu' ),
651651
$toggle_button_content,
652652
$toggle_close_button_content

packages/block-library/src/rss/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function render_block_core_rss( $attributes ) {
2020
$rss = fetch_feed( $attributes['feedURL'] );
2121

2222
if ( is_wp_error( $rss ) ) {
23-
return '<div class="components-placeholder"><div class="notice notice-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</div></div>';
23+
return '<div class="components-placeholder"><div class="notice notice-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . esc_html( $rss->get_error_message() ) . '</div></div>';
2424
}
2525

2626
if ( ! $rss->get_item_quantity() ) {
@@ -48,8 +48,8 @@ function render_block_core_rss( $attributes ) {
4848
if ( $date ) {
4949
$date = sprintf(
5050
'<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',
51-
date_i18n( get_option( 'c' ), $date ),
52-
date_i18n( get_option( 'date_format' ), $date )
51+
esc_attr( date_i18n( get_option( 'c' ), $date ) ),
52+
esc_attr( date_i18n( get_option( 'date_format' ), $date ) )
5353
);
5454
}
5555
}

packages/block-library/src/search/index.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,12 @@ function styles_for_block_core_search( $attributes ) {
367367
// Add color styles.
368368
$has_text_color = ! empty( $attributes['style']['color']['text'] );
369369
if ( $has_text_color ) {
370-
$button_styles[] = sprintf( 'color: %s;', esc_attr( $attributes['style']['color']['text'] ) );
370+
$button_styles[] = sprintf( 'color: %s;', $attributes['style']['color']['text'] );
371371
}
372372

373373
$has_background_color = ! empty( $attributes['style']['color']['background'] );
374374
if ( $has_background_color ) {
375-
$button_styles[] = sprintf( 'background-color: %s;', esc_attr( $attributes['style']['color']['background'] ) );
375+
$button_styles[] = sprintf( 'background-color: %s;', $attributes['style']['color']['background'] );
376376
}
377377

378378
$has_custom_gradient = ! empty( $attributes['style']['color']['gradient'] );
@@ -399,9 +399,9 @@ function styles_for_block_core_search( $attributes ) {
399399
}
400400

401401
return array(
402-
'input' => ! empty( $input_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $input_styles ) ) ) : '',
403-
'button' => ! empty( $button_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $button_styles ) ) ) : '',
404-
'wrapper' => ! empty( $wrapper_styles ) ? sprintf( ' style="%s"', safecss_filter_attr( implode( ' ', $wrapper_styles ) ) ) : '',
402+
'input' => ! empty( $input_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $input_styles ) ) ) ) : '',
403+
'button' => ! empty( $button_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $button_styles ) ) ) ) : '',
404+
'wrapper' => ! empty( $wrapper_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $wrapper_styles ) ) ) ) : '',
405405
'label' => ! empty( $label_styles ) ? sprintf( ' style="%s"', esc_attr( safecss_filter_attr( implode( ' ', $label_styles ) ) ) ) : '',
406406
);
407407
}

packages/widgets/src/blocks/legacy-widget/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function render_block_core_legacy_widget( $attributes ) {
3434

3535
if ( isset( $attributes['instance']['encoded'], $attributes['instance']['hash'] ) ) {
3636
$serialized_instance = base64_decode( $attributes['instance']['encoded'] );
37-
if ( wp_hash( $serialized_instance ) !== $attributes['instance']['hash'] ) {
37+
if ( ! hash_equals( wp_hash( $serialized_instance ), (string) $attributes['instance']['hash'] ) ) {
3838
return '';
3939
}
4040
$instance = unserialize( $serialized_instance );

packages/widgets/src/blocks/widget-group/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function render_block_core_widget_group( $attributes, $content, $block ) {
2828
$html = '';
2929

3030
if ( ! empty( $attributes['title'] ) ) {
31-
$html .= $before_title . $attributes['title'] . $after_title;
31+
$html .= $before_title . esc_html( $attributes['title'] ) . $after_title;
3232
}
3333

3434
$html .= '<div class="wp-widget-group__inner-blocks">';

0 commit comments

Comments
 (0)