diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index e08ec3425..64fd32077 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -34,7 +34,7 @@ class Assets const JS_REGEX = '/.\.js$/i'; /** @const Regex to match CSS urls */ - const CSS_URL_REGEX = '{url\([\'\"]?((?!http|//).*?)[\'\"]?\)}'; + const CSS_URL_REGEX = '{url\(([\'\"]?)(.*?)\1\)}'; /** @const Regex to match CSS sourcemap comments */ const CSS_SOURCEMAP_REGEX = '{\/\*# (.*) \*\/}'; @@ -1149,13 +1149,18 @@ class Assets // Then replace the old url with the new one $file = preg_replace_callback(self::CSS_URL_REGEX, function ($matches) use ($relative_path) { - $old_url = $matches[1]; + $old_url = $matches[2]; // ensure this is not a data url if (strpos($old_url, 'data:') === 0) { return $matches[0]; } + // ensure this is not a remote url + if ($this->isRemoteLink($old_url)) { + return $matches[0]; + } + $new_url = $this->base_url . ltrim(Utils::normalizePath($relative_path . '/' . $old_url), '/'); return str_replace($old_url, $new_url, $matches[0]);