Project

General

Profile

Actions

Bug #90330

open

Wrong publicUrl for FAL files in non-public storages generated from CLI

Added by Stephan Großberndt almost 5 years ago. Updated over 1 year ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2020-02-05
Due date:
% Done:

0%

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

Description

In at least TYPO3 9.5.13 fetching the public url of a FAL \TYPO3\CMS\Core\Resource\File located in a non-public storage using $file->getPublicUrl() from the commandline in a Symfony command returns

http:///var/www/example.org/www/typo3/sysext/core/bin/index.php?eID=dumpFile&t=f&f=[fileUid]&token=[token]

Using $file->getPublicUrl(TRUE) returns

../../../../http://var/www/example.org/www/typo3/sysext/core/bin/index.php?eID=dumpFile&t=f&f=[fileUid]&token=[token]

Last changes to that area were done in
https://review.typo3.org/c/Packages/TYPO3.CMS/+/57240/11/typo3/sysext/core/Classes/Resource/ResourceStorage.php#1304
https://review.typo3.org/c/Packages/TYPO3.CMS/+/53140/8/typo3/sysext/core/Classes/Resource/ResourceStorage.php#1297
https://review.typo3.org/c/Packages/TYPO3.CMS/+/53789/5/typo3/sysext/core/Classes/Resource/ResourceStorage.php#1304

This should be a valid URL not mangling local file paths with eID-GET-Parameters.

For TYPO3 9+ it probably should take site configuration in account, otherwise it would even help if at least just the relative path

/index.php?eID=dumpFile&t=f&f=[fileUid]&token=[token]

would be returned


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #100361: "vendor/bin" in absolute URL from f:uri.resource in command controllerNew2023-03-30

Actions
Actions #1

Updated by Stephan Großberndt almost 5 years ago

My current workaround:


    /**
     * Cached public URL
     *
     * @var string
     */
    private $publicSiteUrl = '';

    /**
     * Cached wrong local path from File::getPublicUrl()
     *
     * @var string
     * @link https://forge.typo3.org/issues/90330
     */
    private $publicUrlLocalPath = '';

    /**
     * Workaround for "Wrong publicUrl for FAL files in non-public storages generated from CLI" 
     *
     * @param File $file
     * @return string
     * @throws SiteNotFoundException
     * @link https://forge.typo3.org/issues/90330
     */
    protected function getPublicUrl(File $file): string {

        if (empty($this->publicUrlLocalPath)) {
            $this->publicUrlLocalPath = 'http://' . Environment::getPublicPath() . '/typo3/sysext/core/bin/';
        }
        if (empty($this->publicSiteUrl)) {
            $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
            $this->publicSiteUrl = $siteFinder->getSiteByIdentifier('identifier-of-my-site')->getBase();
        }

        $publicUrl = $file->getPublicUrl();
        if (substr($publicUrl, 0, 8) === 'http:///') {
            $publicUrl = str_replace($this->publicUrlLocalPath, $this->publicSiteUrl, $publicUrl);
        }

        return $publicUrl;
    }
Actions #2

Updated by Georg Ringer almost 5 years ago

  • Status changed from New to Accepted
Actions #3

Updated by Stephan Großberndt over 1 year ago

This issue is still present in TYPO3 v12, here $file->getPublicUrl() and $file->getPublicUrl(TRUE) both return

http://bin/index.php?eID=dumpFile&t=f&f=2096&token=bd6e0cc99d3c2a7a6745416bff82d61ce87d44dd
Actions #4

Updated by Stephan Großberndt about 1 year ago

  • Related to Bug #100361: "vendor/bin" in absolute URL from f:uri.resource in command controller added
Actions

Also available in: Atom PDF