Project

General

Profile

Actions

Bug #65765

closed

findBestMatchingStorageByLocalPath produces wrong identifier

Added by nemo m about 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-03-16
Due date:
% Done:

0%

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

Description

[`ResourceFactory->findBestMatchingStorageByLocalPath()`](https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_6-2/typo3/sysext/core/Classes/Resource/ResourceFactory.php#L194) produces a wrong identifier.

Example input:

    fileadmin/_processed_/csm_2048_d103438c3b.jpg

Expected output (via output parameter):
    /_processed_/csm_2048_d103438c3b.jpg

Actual output:
    _processed_/csm_2048_d103438c3b.jpg

The missing slash leads to files not being found. This issue occurs due to the following cropping:
       if ($bestMatchStorageUid !== 0) {
        $localPath = substr($localPath, $bestMatchLength);
    }

Example:

File `fileadmin/foo` is requested, the local storage `basePath` is `fileadmin/`, `PathUtility::getCommonPrefix(array($basePath, $localPath))` therefore returns `fileadmin/` as common prefix.

This leads to the slash being removed. In my opinion this code is bugged.

Since `PathUtility::getCommonPrefix()` seems to always produce at least `/`, the code should be

     $matchLength = strlen(PathUtility::getCommonPrefix(array($basePath, $localPath))) - 1;

Instead of
     $matchLength = strlen(PathUtility::getCommonPrefix(array($basePath, $localPath)));

IMO.

Actions

Also available in: Atom PDF