Hotlinking fails with some weired filenames

Created on 24 February 2021, about 4 years ago
Updated 31 January 2023, about 2 years ago

Problem/Motivation

We have some weirdo filenames like

sites/default/files/styles/teaser_squared_1_1_480/public/IM-FOCUS_#problematic.png

which are wrongly hotlinked to without url encoding and therefore not found and proxied.

Steps to reproduce

Use an image containing a hash in url (e.g. IM-FOCUS_#problematic.png)

$location in stage_file_proxy/src/EventSubscriber/ProxySubscriber.php L168

will turn into a mess like

sites/default/files/styles/teaser_squared_1_1_480/public/IM-FOCUS_?itok=C9bCnXSv#problematic.png

instead of the expected

sites/default/files/styles/teaser_squared_1_1_480/public/IM-FOCUS_%23problematic.png?itok=drJ-o_6T

Proposed resolution

Urlencode $relative_path variable.

Yes. I'm sure you should prevent such filenames in other places, but that's what we have to deal with :)

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany digitaldonkey

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024