One error message like error renaming file
There are two error messages:
The first one is like expected: Error renaming item
The second one is irritating for the user: move file is not possible as destination already exists
Joomla 5.2.4
PHP 8.3
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
bug
|
can i work n this issue
We don't assign issues. Anyone can work on it
Is the bug still there in the latest version?
@Amaan-ali03 check yourself and if still present then please work on a fix
@Amaan-ali03 check yourself and if still present then please work on a fix
Sure sir.
Yes there is a bug when we add $ to a file name
as I'm fixing it should I just block the invalid filename or show something like invalid filename ...
suggestions would be appreciated.
For usabliliy it is important that the user understands why something does not work. There should be a message.
I was looking into this issue and I’ve noticed inconsistent behavior when using symbols (like $) in filenames.
If the filename only has symbols (e.g. $$$), it throws an error.
If the filename has symbols and letters (e.g. abc$$ or $$abc or a$b or
In my opinion there are 3 ways to fix this:
I'm interested in your thoughts and if there are any potential side effects with either method in our current codebase.
As you spotted the filename is sanitized by the removal of those characters on save. Obviously if you remove all the characters in the filename you end up trying to save a file with no name and therefore get the error
@brianteeman Thank you for reaching out, but i think i was not clear to explain my point of view in solving the issue.
It is obvious we cant save a file without filename, but what if the file name contains a symbol (eg. $ or any other symbol).
The 1st fix which i mentioned (Sanitize the symbols showing the error message why we can't use those symbols) is when the user tries to save a file with characters and symbols (eg. abc$$ or $$abc) in it , in joomla it just cut down the symbols and rename the file with the characters (abc in this case) with a success message without stating the reason why we can't use those symbols. So my fix to this problem was to show the error message why we can't use those symbols to rename the file.
The 2nd fix which i mentioned (When any symbols like this are used, trigger the error message instantly) is when the user tries to save the file with characters and symbols (eg. abc$$ or $$abc) , so my fix to this problem is to show the error message instantly to not make use of such symbols before user click the save button to rename the file (instant error message).
The 3rd fix (Allow to use symbols like this) was just to allow to make use of such symbols to name their file.
I hope i was clear with it. Please reach out back if I misunderstood you. And state the fix with which i can proceed to fix the issue
@STUDYHUB02 for solution 3 : symbols like '$' can't be allowed to use in usernames due to potential security reasons.
and is it not better to check for '$' and throw an error inside the function move ?
it is also important to note that this bug is not specific to '$' and is affected by several other characters such as '!' as well
the above PR :
(i) throws an error whenever an invalid character is used in the filename and the error thrown explains the reason properly ( "File name must only have alphanumeric characters and no spaces." )
(ii) the normalization logic has been removed leading to stricter validation
[ im a beginner, any feedback is appreciated and apologies if im breaking any convention followed in this org ]
the above PR : (i) throws an error whenever an invalid character is used in the filename and the error thrown explains the reason properly ( "Could not make the file name safe. The file name contains invalid characters." ) (ii) the normalization logic has been removed leading to stricter validation
[ im a beginner, any feedback is appreciated and apologies if im breaking any convention followed in this org ]
Did you test the case when the user renames a file to a name that ends with full-stop " . " ?
@krishnaGandhi11 no, but if that character (.) gets sanitised ( ie not allowed ) then the mentioned error will be thrown
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-03-23 06:53:24 |
Closed_By | ⇒ | alikon |
Hello, @paternax
I appreciate your detailed report on this issue. I tried reproducing the bug on Joomla 5.2.5-dev, but I was unable to encounter the same problem. Renaming an image file with a "$" symbol works correctly without any duplicate error messages.
It’s possible that this issue was specific to Joomla 5.2.4. Are you currently using 5.2.4? If so, I’d recommend updating to 5.2.5-dev and testing again. If the issue still exists in 5.2.5, please let me know—I may have missed something while verifying the bug, and I’d be happy to recheck.