Verify folder paths (field file directory settings allows invalid characters and uploads fail)

Created on 1 February 2016, over 9 years ago
Updated 26 May 2025, 19 days ago

Note: no dev version checked out to verify it is still an issue.

Issue

On a file / image field you can save an invalid folder name, like "public://" which was incorrectly migrated with the FileField settings.

When trying to upload a file, you will get a generic File could not be uploaded error.

I am on a Windows box, so : is an invalid character, and // would also be invalid on any system (empty string as a folder name).

Suggested possible solution

Using tokens here would make the issue even worse, and make validation nearly impossible here. So maybe ensure a clean folder path when creating the directory during the save process?

Feature request
Status

Needs work

Version

11.0 🔥

Component

file.module

Created by

🇦🇺Australia alan d.

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India mohit_aghera Rajkot

    Currently in Drupal 11.x, it still allows to provide folder path like "public://".
    I believe we should add a validation to ensure that path doesn't contain URI scheme field in the path.

    We can use the stream_wrapper_manager service to fetch all the schemes and validate that path doesn't contain string like "{uri_stream}://"

Production build 0.71.5 2024