benjaminkott / bootstrap_package

Bootstrap Package delivers a full configured theme for TYPO3, based on the Bootstrap CSS Framework.
https://www.bootstrap-package.com/
MIT License
337 stars 203 forks source link

bad url produce by ScssParser #1108

Open fabmen opened 2 years ago

fabmen commented 2 years ago

Bug Report

Prerequisites

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

agendartobias commented 2 years ago

I have simmilar problem with all scss files when "debuger" is on

image

Gitsko commented 1 year ago

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 ?