File links for paths with reserved characters ( '+' & '#' '?') generated wrong for external streamWrappers.

Created on 11 October 2022, almost 3 years ago
Updated 15 July 2025, about 19 hours ago

Problem/Motivation

When you upload a file to an external streamWrapper (s3fs) where the filename contains contains '+' or '#' symbol, the preview link (beside remove button) in node edit/create is not encoded.
(see comment #2 for more technical details)

Result: https://mybucket.s3.ap-southeast-1.amazonaws.com/files/2022-10/filename+...

Expected: https://mybucket.s3.ap-southeast-1.amazonaws.com/files/2022-10/filename%...

The image is showing correct in the preview thumbnail and published page but not the link on the filename.

Running LAMP stack with Drupal 9.4.7 & s3fs 8.x-3.0-beta6.
If uninstalled s3fs and upload image via default setting, the link will encode "+" to %2B.

Steps to reproduce

1. Install s3fs and set use S3 for public:// files
2. In the node image field set upload destination to S3 File System / Public files
3. Upload an image with "+" symbol in the file name. E.g. filename+.jpg
4. Once image uploaded, click on the "filename" and the preview pop up is using /filename+.jpg instead of /filename%2B.jpg which will show Access Denied

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

file system

Created by

πŸ‡²πŸ‡ΎMalaysia hunchang

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This came up as a daily BSI target

    Is it only possible to replicate with s3? I don't have a free one I can verify with but would be good to check if still an issue.

  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    This bug impacts any streamWrapper that generates FQDN based URL's that are not the local server.

    This should include any of following:
    s3fs
    All Flysystem streamWrappers that are not local (s3, ftp, etc)
    remote_stream_wrapper (when used with remote_stream_wrapper_widget)

    Quick tested with RSW since I had it open in another lab for a different reason (this would be D10.5 as it has not yet been ported to D11) and it is easier to manipulate the URL's with:

    URL: http://www.example.org/test/test%23not_fragment.txt
    Rendered: http://www.example.org/test/test#not_fragment.txt

    I don't have a free one I can verify with

    You might consider the localstack/localstack docker image. S3fs uses this image in all of its GitlabCi runs to emulate a server, not 100% feature complete to AWS S3 however it is sufficient enough for testing the majority of code operations with that streamWrapers will utilize.

    Normally I would not expect non-s3fs devs to be setup with a S3 development lab, however as there are multiple S3 contrib modules available and Drupal Core developers could benefit from having at least one external stream wrapper installed in their dev labs to test scenarios it may be worth keeping this in mind as a tool going forward.

  • πŸ‡ΊπŸ‡ΈUnited States cmlara

    Note:
    πŸ“Œ Disallow dangerous filenames e.g. command injection characters Active will likely make this issue harder to test with direct uploads should it ever be merged as it will transliterate 'special' characters masking that there is a flaw in how streamWrapper url's are processed.

    remote_stream_wrapper however will likely make a great sample candidate (assuming it is ported to latest versions) as it does not upload a file, yet still creates a managed file entity.

Production build 0.71.5 2024