Project

General

Profile

Actions

Bug #104440

open

stripPathSitePrefix breaks file path

Added by Franz Holzinger 8 days ago. Updated 7 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2024-07-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The internal method PathUtility::stripPathSitePrefix breaks the formerly correct path to files.
This happens if the class ImageContentObject (IMAGE) is used to create an Image HTML out of an image file.
There is a second error when TYPO3 wrongly generates an image file with duplicate slashes. As a side effect of stripPathSitePrefix the duplicate slash is fixed. But when a Middleware call is used then there is no such duplicate slash bug. This leads to the result that the slash before fileadmin is removed for a Middleware and the HTML image source is:

src="fileadmin/myimage.png" 

instead of

src="/fileadmin/myimage.png" 

Therefore the image is not found by the browser with the new TYPO3 routing enhancer.

    /**
     * Strip first part of a path, equal to the length of public web path including trailing slash
     *
     * @internal
     */
    public static function stripPathSitePrefix(string $path): string
    {
        debug ($path, 'stripPathSitePrefix $path: demoshop12//fileadmin/ Doppelter falscher Slash');
        debug (Environment::getPublicPath(), 'stripPathSitePrefix Environment::getPublicPath()');
        $result = substr($path, strlen(Environment::getPublicPath() . '/'));
        debug ($result, 'stripPathSitePrefix $result /fileadmin mit Slash vorne');

        return $result;
    }


Files

pathutility-debug.html (4.92 KB) pathutility-debug.html Franz Holzinger, 2024-07-19 19:51
pathutility-middleware-debug.html (20.1 KB) pathutility-middleware-debug.html Franz Holzinger, 2024-07-20 06:24
Actions

Also available in: Atom PDF