Steps to reproduce

  1. Configure webform_encrypt and file_encrypt as per https://www.drupal.org/project/webform_encrypt/issues/3038902#comment-13...
  2. Set up a webform with an encrypted file field
  3. Submit the form with a file
  4. View the submission
  5. Click the file link

Expected result

The file should be available for download from e.g. http://localhost:8090/encrypt/files/webform/encrypt_webform_test/213689/...

Actual result

The page responds with 404, but if you manually add the query parameter, it behaves as expected, eg. http://localhost:8090/encrypt/files/?file=webform/encrypt_webform_test/2...

Notes

I had wondered if #2946320: Fix download route when installed with the redirect module may be related, but the issue still occurred with the patch from that issue, and with redirect uninstalled.

Comments

malcomio created an issue. See original summary.

malcomio’s picture

Possibly some differences depending on the file type:

PDFs are downloaded as expected from the URL with no query parameter, e.g. http://localhost:8090/encrypt/files/webform/encrypt_webform_test/213690/...

txt and jpg files respond with 404 if there's no query parameter, e.g. http://localhost:8090/encrypt/files/webform/encrypt_webform_test/213691/..., but are rendered in the browser with the query parameter, e.g. http://localhost:8090/encrypt/files/?file=webform/encrypt_webform_test/2...

May need to look at how core handles the different file types?

malcomio’s picture

Project: Webform Encrypt » File Encrypt

This isn't specific to Webform Encrypt - it also happens for encrypted file fields on nodes.

malcomio’s picture

Seems to be an issue with the configuration of Fast 404 - need to whitelist the encryption path using fast404_string_whitelisting - we should update the README to mention this.

luisrc7’s picture

Yes, after disabling the Fast404 module we can get to the encrypted filesystem as Malcolm mentioned.
This is already documented in the Fast404 Readme -> https://git.drupalcode.org/project/fast_404/-/blob/8.x-2.x/README.txt
n Advanced Install point No. 5.
At the moment I think we also need the redirections patch https://www.drupal.org/project/file_encrypt/issues/2946320#comment-12707793
Will validate the different scenarios and reply here the solution that worked for us.

==== Update: ====

After applying the Fast_404 configuration like:
$settings['fast404_string_whitelisting'] = ['/encrypt/files'];
And applying the patch to make the file_encrypt module work with Redirect module from this issue https://www.drupal.org/project/file_encrypt/issues/2946320#comment-12707793
The files in the Webform are working as expected, we are able to download and read files from the encrypted:// filesystem.

g.mustapha’s picture

StatusFileSize
new2.84 KB

I had the similar problem with webform, but the issue was that when you try to download the PDF file, the profile is supposed to be retrieved from the URI, but this throws an error exception. :
Exception: Missing profile: . in Drupal\file_encrypt\EncryptStreamWrapper->extractEncryptionProfile() (line 184 of /var/www/html/docroot/modules/contrib/file_encrypt/src/EncryptStreamWrapper.php).

This is a fix ,
Have a good day

g.mustapha’s picture

StatusFileSize
new2.56 KB
rutiolma’s picture

Status: Active » Closed (duplicate)
Related issues: +#3155174: Conflict with IMCE module

The patch on this issue fixes several issues which are being tackled on #2946320 and #3155174
And, as explained at comment #5, the issue reported here doesn't exist if fast404 whitelist is set.

I'm closing this in favor of #2946320 and #3155174