Make WordPress Core

Opened 22 months ago

Last modified 22 months ago

#57246 new defect (bug)

Duotone SVG function does not check for CSS variable color format

Reported by: mattf10's profile mattf10 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: needs-patch
Focuses: css Cc:

Description (last modified by sabernhardt)

The function wp_get_duotone_filter_svg and/or wp_tinycolor_string_to_rgb do not verify the format of the color code passed to it. My theme uses a CSS variable var(--nv-text-dark-bg). After getting $color from wp_tinycolor_string_to_rgb, it assumes the color array has valid values. Since the original color is not one of the expected formats, this generates the following warnings:

PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 422
PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 423
PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 424
PHP message: PHP Warning:  Trying to access array offset on value of type null in /wp-includes/block-supports/duotone.php on line 425

Please change one or the other method to check for CSS variables before using values from $color array.

Change History (3)

#1 @mattf10
22 months ago

  • Summary changed from Duotune filter svg assumes hex to Duotune filter svg does not check for css var color format

#2 @sabernhardt
22 months ago

  • Component changed from General to Themes
  • Description modified (diff)
  • Focuses css added
  • Keywords needs-patch added
  • Summary changed from Duotune filter svg does not check for css var color format to Duotone SVG function does not check for CSS variable color format

Hi and thanks for the report!

I have similar warnings when I add a Cover block with duotone in the Neve theme.

#3 @sabernhardt
22 months ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.