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 #2

Updated by Garvin Hicking 8 days ago

  • Status changed from New to Needs Feedback

Thanks for reporting! Could you maybe provide a minimal example on how to reproduce the issue, ideally with v13/main? This would help analysis and help create tests for the behaviour.

Actions #3

Updated by Franz Holzinger 7 days ago

Here is the PathUtility::stripPathSitePrefix debug output coming from the xajax extension's Middleware.

Actions #4

Updated by Franz Holzinger 7 days ago

You can reproduce this with tt_products if you build a simple view with a product variant and add 2 articles with different prices to this product. The image must change if the variant select box is clicked by the mouse pointer. The tt_products_articles exclude extension settings must not exclude the image_uid.

A bug fix is also needed for TYPO3 12.

templateFile = EXT:addons_tt_products/Resources/Private/Templates/collection/example_template_bill_de.tmpl

I can build an environment for TYPO3 13 and give you access.

Actions #5

Updated by Garvin Hicking 7 days ago

That is sadly not a "minimal" example and has too many dependencies. I would need an example with just a few lines to reproduce this behavior at some point, maybe this is possible for you to create?

Personally, I can not offer to debug a complex environment due to time restrictions.

Actions #6

Updated by Franz Holzinger 7 days ago ยท Edited

I have no idea where else the duplicate slash inside of file paths will happen.
I cannot produce an example with some lines of PHP code which uses the xajax extension to create an image after running its middleware.
I have already added the necessary debug output in the attached HTML files to view them in a HTML browser. Tell me if you need more debug infos.

Actions #7

Updated by Garvin Hicking 7 days ago

I can only help with an example code that I can run to receive the debug output. Maybe the xajax middleware is doing something that triggers this. I would need a minimal middleware that makes the issue reproducible.

Of course if someone else knows what to fix with the given information, feel free to take over.

Actions

Also available in: Atom PDF