benjaminkott / benjaminkott/bootstrap_package

bad url produce by ScssParser

Open
#1,108 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
355
Forks
212
Avg merge
1h 4m
Merged PRs (30d)
31

Description

# 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](https://github.com/issues?q=is%3Aissue+user%3Abenjaminkott+repo%3Abenjaminkott%2Fbootstrap_package)
to see if your bug or enhancement is already reported?

## Description

With a scss code like this:
``` scss
@ 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 is`mysite/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

```php
$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`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at ScssParser around lines 136-155 and reproduce the font-face example, tracing the paths through PathUtility and TYPO3_SITE_PATH handling. Check that missing files are handled correctly and that generated font URLs resolve from the configured site path without duplicating it.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, scss
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.