Fix #1729 @import of external URL in concatenated CSS

This commit is contained in:
Kijin Sung 2021-06-19 19:39:57 +09:00
parent 858b3f68b1
commit b01a148675
4 changed files with 15 additions and 1 deletions

View file

@ -339,6 +339,10 @@ class Formatter
$import_content = '';
$import_files = array_map(function($str) use($filename, $import_type) {
$str = trim(trim(trim(preg_replace('/^url\\(([^()]+)\\)$/', '$1', trim($str))), '"\''));
if (preg_match('!^(https?:)?//!i', $str))
{
return $str;
}
if ($import_type === 'scss')
{
if (($dirpos = strrpos($str, '/')) !== false)
@ -367,10 +371,14 @@ class Formatter
}, explode(',', $matches[1]));
foreach ($import_files as $import_filename)
{
if (file_exists($import_filename))
if (!preg_match('!^(https?:)?//!i', $import_filename) && file_exists($import_filename))
{
$import_content .= self::concatCSS($import_filename, $target_filename, false);
}
else
{
$import_content .= '@import url("' . escape_dqstr($import_filename) . '");';
}
}
return trim($import_content);
}, $content);