Project

General

Profile

Actions

Bug #65765

closed

findBestMatchingStorageByLocalPath produces wrong identifier

Added by nemo m over 9 years ago. Updated over 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 #1

Updated by Markus Klein over 9 years ago

  • Description updated (diff)
Actions #2

Updated by Markus Klein over 9 years ago

  • Status changed from New to Needs Feedback

What is the actual usecase?

You're talking about an internal function here, so I guess you're not using it directly.
Why should a path relative to the storage start with a leading slash?

Please give us some more insight on what your problem is, or what you want to achieve, Thanks.

Actions #3

Updated by Alexander Opitz over 9 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions

Also available in: Atom PDF