Problem/Motivation
In the latest release 3.0.8 my image fields that are configured to accept only specific file types now allow to upload files using extensions that are not in the allowed list.
Steps to reproduce
- Create an image field with the following settings:
- Upload destination: Rokka
- Allowed file extensions: "jpg jpeg"
- Use the entity create form to upload an image to the field.
Expected result: I can only upload images with the extensions jpg or jpeg.
Actual result: I can upload images with extensions jpg, jpeg, pdf, eps, webp, svg, tiff, heic.
Proposed resolution
Don't change the configured file extensions.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Screenshot 2024-07-18 at 11-10-02 Edit term Drupal.png | 7.08 KB | pfrenssen |
| #5 | Screenshot 2024-07-18 at 11-08-14 Edit term Drupal.png | 6.07 KB | pfrenssen |
Issue fork rokka-3461515
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pfrenssenComment #4
ayalon commentedIt was like that before. But for all image fields. Now it is limited to rokka fields.
Comment #5
pfrenssenStandard image field when using Rokka 3.0.6:
After updating to Rokka 3.0.8:
The regression has been introduced in commit: 5387a5f.
The previous implementation was extending the allowed extensions in
RokkaImageFactory::getSupportedExtensions()which was OK since the image factory needs to know which extensions it can handle. This does not affect user facing forms in any way.In the commit the extensions that are supported by Rokka but not by the default GD2 image library are being injected in user facing forms:
There is no need to append the extensions in this way. The File module already allows the site builder to set the allowed extensions using the Field UI. They can just add PDF or other extensions there.
From a different perspective: the file extensions that can be stored on Rokka should not be controlled on form level, but rather by the image manipulation API. Then they will work correctly also when files are added outside of forms. We should use
ImageToolkitInterface::getSupportedExtensions(), as is proposed as part of the fix for #3461471: Fatal error "Stream must be a resource".Comment #7
pfrenssen