diff --git a/lib/compat/wordpress-6.1/blocks.php b/lib/compat/wordpress-6.1/blocks.php index b22fb1fe18aee8..b8f70f50aa44ce 100644 --- a/lib/compat/wordpress-6.1/blocks.php +++ b/lib/compat/wordpress-6.1/blocks.php @@ -38,11 +38,12 @@ function gutenberg_safe_style_attrs_6_1( $attrs ) { */ function gutenberg_safecss_filter_attr_allow_css_6_1( $allow_css, $css_test_string ) { if ( false === $allow_css ) { - // Allow some CSS functions. - $css_test_string = preg_replace( '/\b(?:calc|min|max|minmax|clamp)\(((?:\([^()]*\)?|[^()])*)\)/', '', $css_test_string ); - - // Allow CSS var. - $css_test_string = preg_replace( '/\(?var\(--[\w\-\()[\]\,\s]*\)/', '', $css_test_string ); + // Allows some CSS functions and CSS vars. + $css_test_string = preg_replace( + '/\b(?:var|calc|min|max|minmax|clamp)(\((?:[^()]|(?1))*\))/', + '', + $css_test_string + ); // Check for any CSS containing \ ( & } = or comments, // except for url(), calc(), or var() usage checked above.