diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 56a70df5b84..19b21be73e7 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -8,6 +8,7 @@ Yii Framework 2 Change Log - Bug #4889: Application was getting into redirect loop when user wasn't allowed accessing login page. Now shows 403 (samdark) - Bug #5402: Debugger was not loading when there were closures in asset classes (samdark) - Bug #5452: Errors occurring after the response is sent are not displayed (qiangxue) +- Bug #5521: Fixed `yii\console\controllers\AssetController` breaks CSS URLs, which start from '/' (klimov-paul) - Bug #5570: `yii\bootstrap\Tabs` would throw an exception if `content` is not set for one of its `items` (RomeroMsk) - Bug #5584: `yii\rbac\DbRbacManager` should not delete items when deleting a rule on a database not supporting cascade update (mdmunir) - Bug #5601: Simple conditions in Query::where() and ActiveQuery::where() did not allow `yii\db\Expression` to be used as the value (cebe, stevekr) diff --git a/framework/console/controllers/AssetController.php b/framework/console/controllers/AssetController.php index fb1dc786348..28c568b7086 100644 --- a/framework/console/controllers/AssetController.php +++ b/framework/console/controllers/AssetController.php @@ -565,7 +565,7 @@ protected function adjustCssUrl($cssContent, $inputFilePath, $outputFilePath) $fullMatch = $matches[0]; $inputUrl = $matches[1]; - if (preg_match('/^https?:\/\//is', $inputUrl) || preg_match('/^data:/is', $inputUrl)) { + if (strpos($inputUrl, '/') === 0 || preg_match('/^https?:\/\//is', $inputUrl) || preg_match('/^data:/is', $inputUrl)) { return $fullMatch; } diff --git a/tests/unit/framework/console/controllers/AssetControllerTest.php b/tests/unit/framework/console/controllers/AssetControllerTest.php index e5b7b4fd167..0b1ae94e667 100644 --- a/tests/unit/framework/console/controllers/AssetControllerTest.php +++ b/tests/unit/framework/console/controllers/AssetControllerTest.php @@ -386,6 +386,12 @@ public function adjustCssUrlDataProvider() 'C:\test\base\path\assets\output', '.published-same-dir-class {background-image: url(../input/published_same_dir.png);}', ], + [ + '.static-root-relative-class {background-image: url(\'/images/static_root_relative.png\');}', + '/test/base/path/css', + '/test/base/path/assets/output', + '.static-root-relative-class {background-image: url(\'/images/static_root_relative.png\');}', + ], ]; }