fix: misc suggested changes

* disable resolve_relative_css_refs by default
* variable naming
* using proper path joiner
* test comment typo
This commit is contained in:
Sergey Shevchenko 2022-08-05 15:34:59 +12:00
parent bc9a323418
commit ebb1601d5d
2 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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 */