Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Call esc_attr only once on the whole typography string
  • Loading branch information
tellthemachines authored and ramonjd committed Oct 10, 2022
commit 4039afe03c877ecb7a5a531444dee35eb1062de3
16 changes: 8 additions & 8 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -446,35 +446,35 @@ 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'],
)
)
);

}

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 );
Expand Down