Look at this block of code https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Filesystem/File.php#L86-L90 , we can see that incase transliterator_transliterate
and iconv
functions are available on your server, the makeSafe
method will convert the filename to lowercase. Of course filename does not need to contains all lower case characters to be safe, so that code looks wrong. That prevent uploading files with upper case characters in filename via template manager which PR #34065 is trying to solve but now closed
I think we can solve that by changing this line of code to https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Filesystem/File.php#L89
$file = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", transliterator_transliterate('Any-Latin; Latin-ASCII', $file));
But I could not configure my php installation to have transliterator_transliterate function available to test it myself, so it would be great if someone can check and make PR to address this issue.
The filename should not be converted to lowercase while we call makeSafe
method
The filename is converted to lowercase while we call makeSafe
method when iconv
and transliterator_transliterate
is available on your php setup.
Labels |
Added:
?
|
isn't the point of makesafe is to make the files safe.
if you were to move from a case insensitive os to a case sensitive os you will have problems
also are you sure it is not getSafeName in plugins\filesystem\local\src\Adapter\LocalAdapter.php
Convert filename to lower case does not make the file safe, right? The filename such as Joomla.jpg should be valid, right? So I think convert filename to lower case in makeSafe is not right.
For getSafeName in plugins\filesystem\local\src\Adapter\LocalAdapter.php, it is not related here. The file upload in template manager is not related to that code. The problem is with this line of code https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_templates/src/Helper/TemplateHelper.php#L86
It compares the filename which you are uploading with the filename after calling makeSafe. In your system, the it has transliterator_transliterate and iconv function available, so the makeSafe method return filename in lower case. It is different with the filename which you are uploading, so it is not allowed to upload.
Convert filename to lower case does not make the file safe, right? The filename such as Joomla.jpg should be valid, right? So I think convert filename to lower case in makeSafe is not right.
On a case insensitive filesystem both Joomla.jpg and joomla.jpg are valid
Move the site to a case sensitive filesystem and you have a problem because you have two (or more) files with the exact same name
It compares the filename which you are uploading with the filename after calling makeSafe. In your system, the it has transliterator_transliterate and iconv function available, so the makeSafe method return filename in lower case. It is different with the filename which you are uploading, so it is not allowed to upload.
Tested in Media Upload.
One can upload the file originally with an uppercase, it is just transformed to lowercase by Lower()
May be different in template new file.
Move the site to a case sensitive filesystem and you have a problem because you have two (or more) files with the exact same name
Agree.
Move the site to a case sensitive filesystem and you have a problem because you have two (or more) files with the exact same name
It' exactly vice versa, on a case sensitive file system, Joomla.jpg
and joomla.jpg
are 2 different files, and when you move them to a case insensitive file system you have the problem they overwrite each other. Vice versa, moving from case insensitive file system to case sensitive file system can't be a problem because you move one file only, however it might be cased.
oops - but you get my point.
Yep, I just wanted to be precise so people can better understand it.
But I think makeSafe should not change anything on the casing, that's not the purpose of that function, except if we say only lower case names are safe, but that would be wrong. So I am with @joomdonation regarding this.
The main problem is that there are too many places that are handling uploaded files and they are all using different code/criteria
Upload an image with media manager and it is saved as lowercase
Upload an image with template manager the case is maintained
Images with uppercase extensions are not displayed in template manager
Images with uppercase extensions are displayed in media manager
Rename a file with media manager and you cannot change the case
Try to edit an image that is lowercase with a media-action plugin and it silently fails
Drag and drop an image into the editor and it is converted to lowercase
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-11-29 07:27:03 |
Closed_By | ⇒ | joomdonation | |
Labels |
Added:
No Code Attached Yet
Removed: ? |
Status | Closed | ⇒ | New |
Closed_Date | 2022-11-29 07:27:03 | ⇒ | |
Closed_By | joomdonation | ⇒ |
Labels |
Added:
bug
|
@brianteeman Could you please look at this? You had the issue with upload file contains upper case characters via template manager, so I think your system has these functions available.