diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index baa2de4..2b78011 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -50,8 +50,9 @@ protected function processFile($css_asset) { // Store base path. $this->rewriteFileURIBasePath = $css_base_path . '/'; - // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths. - return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', array($this, 'rewriteFileURI'), $contents); + // Anchor all paths in the CSS with its base URL, ignoring external, + // absolute, and SVG (#) paths. + return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+|\#+)([^\'")]+)[\'"]?\s*\)/i', array($this, 'rewriteFileURI'), $contents); } /** @@ -143,8 +144,8 @@ protected function loadNestedFile($matches) { // Alter all internal _url() paths. Leave external paths alone. We don't need // to normalize absolute paths here (i.e. remove folder/... segments) - // because that will be done later. - return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file); + // because that will be done later. Also ignore SVG paths (#). + return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+|\#+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file); } /** diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 92e2136..4c99c98 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -491,8 +491,9 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { // off the name of the file at the end of the path. $css_optimizer->rewriteFileURIBasePath = base_path() . dirname($paths['source'] . $file) . '/'; - // Prefix all paths within this CSS file, ignoring absolute paths. - $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style); + // Prefix all paths within this CSS file, ignoring external, absolute, and + // SVG (#) paths. + $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+|\#+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style); // Rewrite stylesheet with new colors. $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);