[wp-trac] [WordPress Trac] #57246: Duotone SVG function does not check for CSS variable color format (was: Duotune filter svg does not check for css var color format)

WordPress Trac noreply at wordpress.org
Fri Dec 2 23:02:23 UTC 2022


#57246: Duotone SVG function does not check for CSS variable color format
--------------------------+------------------------------
 Reporter:  mattf10       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Themes        |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  css
--------------------------+------------------------------
Changes (by sabernhardt):

 * keywords:   => needs-patch
 * focuses:   => css
 * component:  General => Themes


Old description:

> 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 'string_to_rbg', 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 422PHP message: PHP
> Warning:  Trying to access array offset on value of type null in /wp-
> includes/block-supports/duotone.php on line 423PHP message: PHP Warning:
> Trying to access array offset on value of type null in /wp-includes
> /block-supports/duotone.php on line 424PHP 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.

New description:

 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 `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.

--

Comment:

 Hi and thanks for the report!

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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57246#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list