From 071c455d12481e5fa7316cc81970e76f6672085c Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Mon, 10 Oct 2022 15:57:26 +1100 Subject: [PATCH] Call esc_attr only once on the whole typography string --- packages/block-library/src/search/index.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index fcb0a5a863ee85..851131a5fb5d7b 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -381,7 +381,7 @@ function styles_for_block_core_search( $attributes ) { } // Get typography styles to be shared across inner elements. - $typography_styles = get_typography_styles_for_block_core_search( $attributes ); + $typography_styles = esc_attr( get_typography_styles_for_block_core_search( $attributes ) ); if ( ! empty( $typography_styles ) ) { $label_styles [] = $typography_styles; $button_styles[] = $typography_styles; @@ -446,7 +446,7 @@ function get_typography_styles_for_block_core_search( $attributes ) { 'font-size: %s;', gutenberg_get_typography_font_size_value( array( - 'size' => esc_attr( $attributes['style']['typography']['fontSize'] ), + 'size' => $attributes['style']['typography']['fontSize'], ) ) ); @@ -454,27 +454,27 @@ function get_typography_styles_for_block_core_search( $attributes ) { } if ( ! empty( $attributes['style']['typography']['fontFamily'] ) ) { - $typography_styles[] = sprintf( 'font-family: %s;', esc_attr( $attributes['style']['typography']['fontFamily'] ) ); + $typography_styles[] = sprintf( 'font-family: %s;', $attributes['style']['typography']['fontFamily'] ); } if ( ! empty( $attributes['style']['typography']['letterSpacing'] ) ) { - $typography_styles[] = sprintf( 'letter-spacing: %s;', esc_attr( $attributes['style']['typography']['letterSpacing'] ) ); + $typography_styles[] = sprintf( 'letter-spacing: %s;', $attributes['style']['typography']['letterSpacing'] ); } if ( ! empty( $attributes['style']['typography']['fontWeight'] ) ) { - $typography_styles[] = sprintf( 'font-weight: %s;', esc_attr( $attributes['style']['typography']['fontWeight'] ) ); + $typography_styles[] = sprintf( 'font-weight: %s;', $attributes['style']['typography']['fontWeight'] ); } if ( ! empty( $attributes['style']['typography']['fontStyle'] ) ) { - $typography_styles[] = sprintf( 'font-style: %s;', esc_attr( $attributes['style']['typography']['fontStyle'] ) ); + $typography_styles[] = sprintf( 'font-style: %s;', $attributes['style']['typography']['fontStyle'] ); } if ( ! empty( $attributes['style']['typography']['lineHeight'] ) ) { - $typography_styles[] = sprintf( 'line-height: %s;', esc_attr( $attributes['style']['typography']['lineHeight'] ) ); + $typography_styles[] = sprintf( 'line-height: %s;', $attributes['style']['typography']['lineHeight'] ); } if ( ! empty( $attributes['style']['typography']['textTransform'] ) ) { - $typography_styles[] = sprintf( 'text-transform: %s;', esc_attr( $attributes['style']['typography']['textTransform'] ) ); + $typography_styles[] = sprintf( 'text-transform: %s;', $attributes['style']['typography']['textTransform'] ); } return implode( '', $typography_styles );