Opened 3 years ago
Last modified 6 months ago
#57246 new defect (bug)
Duotone SVG function does not check for CSS variable color format
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | needs-patch needs-test-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 (5)
#1
@
3 years ago
- Summary changed from Duotune filter svg assumes hex to Duotune filter svg does not check for css var color format
#2
@
3 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
@
10 months 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.