Opened 2 years ago
Last modified 2 weeks ago
#57246 new defect (bug)
Duotone SVG function does not check for CSS variable color format
Reported by: | mattf10 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | needs-patch needs-testing-info reporter-feedback |
Focuses: | css | Cc: |
Description (last modified by )
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 (4)
#1
@
2 years ago
- Summary changed from Duotune filter svg assumes hex to Duotune filter svg does not check for css var color format
#2
@
2 years 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
#4
@
2 weeks ago
- Component changed from Themes to General
- Keywords needs-testing-info reporter-feedback added
wp_get_duotone_filter_svg and wp_tinycolor_string_to_rgb were deprecated in WordPress 6.3.0.
https://core.trac.wordpress.org/ticket/58555
@mattf10 I don't believe this issue was resolved with the updated code. But I would need more detailed reproduction steps to test it.
Hi and thanks for the report!
I have similar warnings when I add a Cover block with duotone in the Neve theme.