Project

General

Profile

Actions

Bug #100683

closed

renameFile aborts if target file = original file, even if sanitizing the filename would result in different target filename

Added by Sybille Peters over 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2023-04-20
Due date:
% Done:

100%

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

Description

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:

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);

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.

  1. Versions
  • 11.5.26
  • main (12-dev)
Actions #1

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #2

Updated by Gerrit Code Review over 1 year ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #3

Updated by Gerrit Code Review over 1 year ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #4

Updated by Sybille Peters over 1 year ago

  • Description updated (diff)
Actions #5

Updated by Gerrit Code Review over 1 year ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #6

Updated by Gerrit Code Review over 1 year ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #7

Updated by Gerrit Code Review over 1 year ago

Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #8

Updated by Gerrit Code Review over 1 year ago

Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #9

Updated by Gerrit Code Review over 1 year ago

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #10

Updated by Gerrit Code Review over 1 year ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #11

Updated by Gerrit Code Review over 1 year ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/78766

Actions #12

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79787

Actions #13

Updated by Sybille Peters over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #14

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF