Problem/Motivation

The File Inspector settings form allows administrators to configure the MIME types that should be inspected. However, the inspection service does not read or apply the inspection.allowed_mime_types configuration.

As a result, files with MIME types not included in the allowed list are still inspected and added to the File Inspector report.

Steps to reproduce

  1. Install and enable the File Inspector module.
  2. Navigate to the File Inspector settings page:
    /admin/config/media/file-inspector.
  3. Remove the existing values from Allowed MIME Types, enter only
    image/png, and save the configuration.
  4. Create two unmanaged test files (file-inspector-test.png & file-inspector-test.txt) in the public file directory (/sites/default/files).
  5. Navigate to the Batch Operations page:
    /admin/config/media/file-inspector/batch.
  6. Run a new file inspection and wait for it to complete.
  7. Navigate to the File Inspector report:
    /admin/reports/file-inspector/files.
  8. Enter file-inspector-test in the File name filter and
    click Filter.
  9. Observe that both file-inspector-test.png and
    file-inspector-test.txt appear in the report, even though only
    image/png is configured as an allowed MIME type.

Proposed resolution

Apply the configured inspection.allowed_mime_types values while processing discovered files. Support both exact MIME types, such as image/jpeg, and wildcard values, such as image/*.

Command icon 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

dkmishra created an issue. See original summary.

lpeidro made their first commit to this issue’s fork.

  • lpeidro committed e2ac6c0e on 1.x
    Issue #3605281: Fix allowed mime types functionality
    
lpeidro’s picture

Status: Active » Fixed

Hello DHmishra, thank you for your colaboration.

I have fixed the issue and added the unit test to ensure the funcionality works and we will not lose it in the future.

Now the system excludes from the analisys the mime types that are not include in the Allowed list.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

dkmishra’s picture

Hi @lpeidro, thank you for the fix and for adding the unit test.

I have tested the changes on my end and can confirm that the issue is resolved. The updated behavior of excluding MIME types not included in the allowed list is working as expected.

Thanks again for the quick turnaround.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.