Script Loader: Prevent normalizing data URIs in _wp_normalize_relative_css_links().

This prevents making data URIs as in `mask-image:url('data:image/svg+xml;utf8,<svg...` relative to the WordPress installation.

Props staatic.
See #54243.
Fixes #55177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52754 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling 2022-02-17 14:45:53 +00:00
parent dd60c77928
commit fcd5d3b495
2 changed files with 9 additions and 0 deletions

View File

@ -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 );

View File

@ -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,<svg></svg>\');}',
'expected' => 'img {mask-image: url(\'data:image/svg+xml;utf8,<svg></svg>\');}',
),
);
}