Bug #104440
open
stripPathSitePrefix breaks file path
Added by Franz Holzinger 8 days ago.
Updated 7 days ago.
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
- 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.
Here is the PathUtility::stripPathSitePrefix debug output coming from the xajax extension's Middleware.
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.
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.
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.
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.
Also available in: Atom
PDF