Project

General

Profile

Bug #100683

Updated by Sybille Peters over 1 year ago

Currently, it is not possible to sanitize a file, simply be renaming it (to the current filename) because the function ResourceStorage::renameFile returns immediately if the new file name is the same as the old filename. 

 code: 

 <pre><code class="php"> 
 public function renameFile($file, $targetFileName, $conflictMode = DuplicationBehavior::RENAME) 
 { 
     // The name should be different from the current. 
     if ($file->getName() === $targetFileName) { 
         return $file; 
     } 
     $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName); 

 </code></pre> 

 This leads to inconsistent behaviour.  

 Example: 

 * Rename "ö.png" to "ö.png" results in "ö.png" (not sanitized) 
 * but renaming "ö.png" to "ö1.png" result in "oe1.png" 

 The file should be renamed, if renaming it results in a different filename. This is the case if target filename = original filename, but sanitizedTargetFileName != originalfilename. 

 Also, if this behaviour were changed, it would be much easier to sanitize filenames. One just need to use the rename function. 


 ## Versions 

 * 11.5.26 
 * main (12-dev)

Back