Different root paths for file_path in File- and StyleDownloadController

Created on 3 December 2023, 12 months ago

Problem/Motivation

When I look up the x-sendfile header generated in the XsendfileFileDownloadController.php, the root path is the path of the Drupal-Installation: x-sendfile: /../private/2023-08/private_file.jpg

The header in XsendfileImageStyleDownloadController.php uses the Root-Directory of the Server as the root-path:x-sendfile: /var/www/html/private/styles/thumbnail/private/2023-08/private_file.jpg

Both approaches can work, but having the module return two different root-paths makes it difficult to distinguish the different paths in Nginx (and probably Apache too).

Steps to reproduce

Activate the Module and create some private pictures. media_library might help with creating ImageStyles.

Proposed resolution

We should decide on one default and then rewrite either of the functions to return an absolute or relative path.

Remaining tasks

  • Decide which root-path to take
  • Switch one of the root-paths

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇩🇪Germany RobinCS

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

Comments & Activities

  • Issue created by @RobinCS
  • First commit to issue fork.
  • 🇩🇪Germany lukas_w

    I created an issue fork changing XsendfileFileDownloadController to also use absolute path. I changed XsendfileFileDownloadController to use absolute paths, because it had also a bug, creating the wrong path.

    If base_path() returned "/" and file_private_path was relative, e.g. ../private, the path in the end would be /../private, which is an invalid absolute path. This is now fixed by using the absolute path of the file.

    (As a side note, for Apache I encountered no problems using both absolute paths and relative paths.)

Production build 0.71.5 2024