Project

General

Profile

Bug #65765

Updated by Markus Klein over 9 years ago

[`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: 
 <pre> 
     

     fileadmin/_processed_/csm_2048_d103438c3b.jpg 
 </pre> 
 

 Expected output (via output parameter): 
 <pre> 
     

     /_processed_/csm_2048_d103438c3b.jpg 
 </pre> 
 

 Actual output: 
 <pre> 
     

     _processed_/csm_2048_d103438c3b.jpg 
 </pre> 
 

 The missing slash leads to files not being found. This issue occurs due to the following cropping: 
 <pre> 
   	 

   	 if ($bestMatchStorageUid !== 0) { 
		 $localPath = substr($localPath, $bestMatchLength); 
	 } 
 </pre> 
 

 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 
 <pre> 
      

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

 Instead of 
 <pre> 
      

      $matchLength = strlen(PathUtility::getCommonPrefix(array($basePath, $localPath))); 
 </pre> 
 

 IMO.

Back