diff --git a/src/View/Requirements_Backend.php b/src/View/Requirements_Backend.php index d0bde0851..1316ae123 100644 --- a/src/View/Requirements_Backend.php +++ b/src/View/Requirements_Backend.php @@ -65,7 +65,7 @@ class Requirements_Backend * @config * @var bool */ - private static $resolve_relative_css_refs = true; + private static $resolve_relative_css_refs = false; /** * Paths to all required JavaScript files relative to docroot @@ -1456,11 +1456,11 @@ MESSAGE $fileUrl = Injector::inst()->get(ResourceURLGenerator::class)->urlForResource($filePath); $fileUrlDir = dirname($fileUrl); $content = preg_replace_callback('#(url\([\n\r\s\'"]*)([^\s\)\?\'"]+)#i', function ($match) use ($fileUrlDir) { - [ $_, $prefix, $relativePath ] = $match; + [ $fullMatch, $prefix, $relativePath ] = $match; if ($relativePath[0] === '/' || false !== strpos($relativePath, '://')) { return $prefix . $relativePath; } - $full = FilesystemPath::canonicalize($fileUrlDir . '/' . $relativePath); + $full = FilesystemPath::canonicalize(FilesystemPath::join($fileUrlDir, $relativePath)); return $prefix . $full; }, $content); return $content; diff --git a/tests/php/View/RequirementsTest.php b/tests/php/View/RequirementsTest.php index 727d26eb0..69144ea5b 100644 --- a/tests/php/View/RequirementsTest.php +++ b/tests/php/View/RequirementsTest.php @@ -280,7 +280,7 @@ class RequirementsTest extends SapphireTest $this->assertStringContainsString( ".p4 { background: url(/four.gif); }", $content, - 'combined css url resolver decoded 4 double-dot when only 4 levels available' + 'combined css url resolver decoded 4 double-dot when only 3 levels available' ); /* COMBINED CSS URL RESOLVER MODIFIED AN ARBITRARY VALUE */