Problem/Motivation

file_save_upload() displays status messages when files are renamed during upload:

  1. "Your upload has been renamed to {filename}."
  2. "For security reasons, your upload has been renamed to {filename}."

These messages provide no actionable value. The upload succeeded and users cannot undo the rename. They just clutter the UI, especially in modals like the media library.

Steps to reproduce

  1. Upload a file with spaces in the filename to any media field
  2. See the unnecessary status message

Proposed resolution

Remove these messages.

User interface changes

No more "renamed" status messages on file upload.

Before:

After:

Issue fork drupal-3563051

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lauriii created an issue. See original summary.

pameeela’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community
StatusFileSize
new75.45 KB
new63.58 KB

Strongly agree with this change, I flagged it for removal in Drupal CMS if we can't get this into core. Manually tested and added screenshots to core, I think it's clear why this is a problem when you see the media modal. As the IS already says, there is nothing actionable, and the actual name of the file is not useful information for the user. Not to mention that the user is in the middle of a separate task that needs to be completed, so the green status message is very confusing.

I'm guessing this was added in the days before media where the feedback made a bit more sense in the context of a direct file upload, but even then it is not useful.

pameeela’s picture

phenaproxima’s picture

Not a stable blocker for us, we will shim around it in #3563050: Sanitising of filenames adds an annoying status message on upload. But certainly a release target.

stephaneq’s picture

One of my clients found this annoying, so I created a patch based on the MR for Drupal 10.6. I’m sharing it here for anyone who might be interested (applied and tested on D 10.5.x and 10.6.x).

longwave’s picture

I checked back and the message was refactored in #3032390: Add an event to sanitize filenames during upload - previously it only displayed if the file was renamed for security reasons. The original message dates back to #693084: Regression: file_munge_filename() extension handling broken by move to File Field which was added as a security improvement.

While showing the message to the user feels a bit pointless, given this is security related I'm wondering if we should keep the ->isSecurityRename() check and send it to watchdog in this case - is that worthwhile?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Moving back to needs review for #7, I can see arguments both ways for the logging. On d.o there are plenty of 'unsafe' file uploads that were renamed but we know they weren't malicious and lots of the people who uploaded them wouldn't have been surprised that the extension got renamed. So I guess it comes down to how often we think people would maliciously try to do this which I have no idea, and whether the logging would help to spot that someone was doing it.

lauriii’s picture

I don't think it hurts to put the security logging back. Added back to the MR 👍

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe the feedback for this one was addressed. Restoring RTBC

  • longwave committed 49348ee1 on 11.x
    task: #3563051 Remove unnecessary status messages from file_save_upload...
longwave’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

As a minor behaviour change this can only go in a minor release, so this will be in 11.4.0.

Committed and pushed 61c592bf375 to main and 49348ee133f to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 61c592bf on main
    task: #3563051 Remove unnecessary status messages from file_save_upload...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jvollebregt-swis’s picture

StatusFileSize
new12.94 KB

Here's a patch for the old 11.x branch version for people using composer patches. Applies on 11.2