Skip to content

Fix/only allow svg when uploading#228

Merged
jeffpaul merged 8 commits intodevelopfrom
fix/only-allow-svg-when-uploading
Oct 16, 2024
Merged

Fix/only allow svg when uploading#228
jeffpaul merged 8 commits intodevelopfrom
fix/only-allow-svg-when-uploading

Conversation

@darylldoyle
Copy link
Copy Markdown
Collaborator

@darylldoyle darylldoyle commented Sep 26, 2024

Description of the Change

Updates the plugin to only add SVGs as an allowed type, when the sanitiser will be able to run on those files.

How to test the Change

Changelog Entry

Added - New feature
Changed - Existing functionality
Deprecated - Soon-to-be removed feature
Removed - Feature
Fixed - Bug fix
Security - Vulnerability
Developer - Non-functional update

Credits

Props @username, @username2, ...

Checklist:

@darylldoyle darylldoyle self-assigned this Sep 26, 2024
@github-actions github-actions bot added this to the 2.3.0 milestone Sep 26, 2024
@github-actions
Copy link
Copy Markdown

@darylldoyle thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this?

@github-actions github-actions bot added needs:feedback This requires feedback to determine next steps. needs:code-review This requires code review. and removed needs:feedback This requires feedback to determine next steps. labels Sep 26, 2024
Copy link
Copy Markdown
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this doesn't work for me, I always get the Sorry, you are not allowed to upload this file type error message.

I think what's happening is there's an earlier mime check that fires before the wp_handle_upload_prefilter filter and since we aren't adding the svg mime until that filter runs, things no longer work.

To test, I'm in the Media Library admin page, with the Grid View on. If I drag and drop an svg image, I get the above error.

@dkotter
Copy link
Copy Markdown
Collaborator

dkotter commented Sep 26, 2024

I was curious on how our E2E tests were passing here when I couldn't get things to work. Looking into that, the uploadMedia command we use goes to /wp-admin/media-new.php and uploads from there. If I go to that page directly, I can upload svgs just fine but as mentioned above, I can't upload svgs from the main Media Library screen, which is interesting

@darylldoyle
Copy link
Copy Markdown
Collaborator Author

Thanks for flagging @dkotter! I too could replicate on the media grid view. I've resolved this and added additional tests for that. I also had to allow uploads from a few additional contexts, because otherwise you could only upload SVGs from the media pages. We might want to add some additional tests for these, but I don't have time at the moment.

@jeffpaul jeffpaul merged commit 718e445 into develop Oct 16, 2024
@jeffpaul jeffpaul deleted the fix/only-allow-svg-when-uploading branch October 16, 2024 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

3 participants