diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 824748b17b..0957dce2d7 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -2781,6 +2781,11 @@ function _wp_normalize_relative_css_links( $css, $stylesheet_url ) { continue; } + // Skip if the URL is a data URI. + if ( str_starts_with( $src_result, 'data:' ) ) { + continue; + } + // Build the absolute URL. $absolute_url = dirname( $stylesheet_url ) . '/' . $src_result; $absolute_url = str_replace( '/./', '/', $absolute_url ); diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 6af0b09866..8e7721d1e9 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -236,6 +236,10 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { 'css' => 'clip-path: url(#image1);', 'expected' => 'clip-path: url(#image1);', ), + 'Data URIs, shouldn\'t change' => array( + 'css' => 'img {mask-image: url(\'data:image/svg+xml;utf8,\');}', + 'expected' => 'img {mask-image: url(\'data:image/svg+xml;utf8,\');}', + ), ); }