bad url produce by ScssParser
Bug Report
Prerequisites
- [x] Can you reproduce the problem on TYPO3 v10.4 LTS
- [x] Can you reproduce the problem on TYPO3 v11.3
- [x] Did you perform a cursory search to see if your bug or enhancement is already reported?
Description
With a scss code like this:
@ font-face {
font-family: "myfont";
src: url ("../fonts/myfont.eot?#iefix") format ("embedded-opentype"),
url ("../fonts/myfont.woff2") format ("woff2"),
url ("../fonts/myfont.woff") format ("woff"),
url ("../fonts/myfont.ttf") format ("truetype"),
url ("../fonts/myfont.svg # myfont") format ("svg");
}
In ScssParser, on line 137 or 139 the file could not be found and the generated path is incomplete.
On line 142, if the typo3 url is like "http://localhost/mysite/", the browser searches for the file in "http://localhost/mysite/mysite/typo3conf/ext/my_theme/Resources/Public/fonts/myfont.ttf ", because the generated path ismysite/typo3conf/ext/my_theme/Resources/Public/fonts/myfont.ttf (line 142) and becomes ../../../../mysite/typo3conf/ext/my_theme/Resources/Public/fonts/myfont.ttf (line 155).
To resolve these two bugs, here is the code from line 136
$file = preg_split("/[?,#]/",$result);
if (substr_compare($result, 'data:', 0, 5, true) !== 0) {
if (is_file(PathUtility::getCanonicalPath($absoluteFilePath . '/' . $file[0]))) {
$result = PathUtility::getCanonicalPath($relativeFilePath . '/' . $result);
} elseif (is_file(PathUtility::getCanonicalPath($absoluteBootstrapPackageThemePath . '/' . $file[0]))) {
$result = PathUtility::getCanonicalPath($relativeBootstrapPackageThemePath . '/' . $result);
}
$result = strpos($result, GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')) === 0 ? substr($result, strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'))) : $result;
}
The generated path is then from the root path typo3conf/ext/my_theme/Resources/Public/fonts/myfont.ttf , then becomes after preg_replace ../../../../typo3conf/ext/my_theme/Resources/Public/fonts/myfont.ttf
I have simmilar problem with all scss files when "debuger" is on

I can confirm the problem when I want to load a custom font via my own scss file, is there already a solution for this ?