Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Fix media manager invalid filename #45141

Open
wants to merge 2 commits into
base: 5.2-dev
Choose a base branch
from

Conversation

STUDYHUB02
Copy link

Pull Request for Issue #45087 .

Summary of Changes

  1. Added an early validation check to detect and block filenames that contain the '$' character.
  2. Updated the language file to include a new language string (COM_MEDIA_ERROR_INVALID_FILENAME) that provides a clear error message when disallowed characters are detected.
  3. These changes ensure that any attempt to rename a file with invalid characters is explicitly rejected, avoiding silent sanitization and user confusion.

Testing Instructions

  1. Open the Media Manager in Joomla.
  2. Test Case 1: Attempt to rename a file using a name composed solely of invalid symbols (e.g., $$$).
    Expected: The operation should immediately fail with the error “Invalid file name.”
  3. Test Case 2: Attempt to rename a file using a name that includes both valid characters and '$' (e.g., abc$$).
    Expected: The operation should be blocked with the same error message, ensuring consistent handling.
  4. Verify that renaming files without any '$' characters works as expected.

Actual result BEFORE applying this Pull Request

  1. When a file is renamed using a name that consists solely of invalid symbols (e.g., $$$), Joomla displays an error indicating that the file name cannot be made safe.
  2. When the file name includes both valid characters and '$' symbols (e.g., abc$$), Joomla silently strips the '$' symbols and renames the file, showing a success message.
  3. This inconsistent behavior can confuse users about what is allowed and what is not.

Expected result AFTER applying this Pull Request

  1. Any attempt to rename a file with a name that contains the '$' character—whether the name is composed solely of '$'
    symbols or mixed with valid characters—will be uniformly blocked.
  2. Users will see a single, clear error message: “Invalid file name.”
  3. This change provides a consistent and clear user experience regarding filename validations in the Media Manager.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

This commit introduces an early validation check to detect and block filenames containing the '$' character. Previously, when renaming a file that included '$', Joomla would silently strip the invalid symbol if mixed with valid characters, leading to inconsistent behavior.

Changes:
- Added a check in move() to throw an exception with a clear error message if the destination filename contains '$'.
- This change ensures that any filename containing '$' is explicitly rejected, providing a consistent user experience.

Reference: [Issue joomla#45087] for details on the problem.
This commit adds a new language string to support the validation of filenames containing the '$' character. The new string, COM_MEDIA_ERROR_INVALID_FILENAME, provides a clear error message when a filename with disallowed characters is encountered, ensuring consistent feedback for users.

Language string added:
COM_MEDIA_ERROR_INVALID_FILENAME="Invalid file name."

This update complements the changes in ApiModel.php for consistent handling of invalid filenames. See Issue joomla#45087 for details.
@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-5.2-dev labels Mar 15, 2025
@STUDYHUB02 STUDYHUB02 changed the title Fix media manager invalid filename [5.2] Fix media manager invalid filename Mar 18, 2025
@imejine
Copy link

imejine commented Mar 21, 2025

I have tested this item 🔴 unsuccessfully on 44e5e47

Tested with mixed results;

https://snipboard.io/bofT4D.jpg

After patch, file is not renamed (success), but the error shown is not the expected string/message (fail).


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45141.

@SumCompanyInc
Copy link

I have tested this item 🔴 unsuccessfully on 44e5e47

i will say that the filename handling tested successfully, however the language en-GB did not seem to pull the right language translation. it showed the language key token, "COM_MEDIA_ERROR_INVALID_FILENAME" instead of, "Invalid file name."

https://snipboard.io/qUKTOx.jpg


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45141.

@Agapiiii
Copy link

The patch Is successful in getting error when renaming a file/folder with a special symbol, but it displays an incorrect error message


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45141.

@Agapiiii
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Change This is for Translators PR-5.2-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants