-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check mime type exists before performing regex #1709
base: develop
Are you sure you want to change the base?
Conversation
Could a potential cause of this bug be from this line: ClassicPress/src/wp-admin/includes/media.php Line 2715 in 0f28773
This call to |
No, I don't think that's cause. I don't think the code in and around that function is loaded on |
I've done a little more checking in the code and that line I linked to matches upstream so probably not the cause of a problem. I'm sure I've seen comments in the code that PHP is not 100% reliable at extracting mime type. Do you have an example file that creates this issue? Your proposed fix looks reasonable but I'd like to see if we can identify the cause earlier in the chain of events if possible. |
A very recent thread on the inaccuracy of mime type detection is at https://forums.phpfreaks.com/topic/318512-problems-getting-mime-type-of-files/ I have quite a few SVGs that I have created from rasterized images using Inkscape. CP never recognizes their mime types. Here's one: |
How are you enabling SVG upload to the Media Library? This is working locally for me, recognised as
|
I'm using a plugin. It was Safe SVG before, now SVG Support. |
Strange one this, I've use my snippet and the SVG Support plugin and both allow upload of the SVG image you linked without anything logged in debug.log or shown on screen as an error. I'll try again next week. |
I can't reproduce it either. |
The function
wp_match_mime_types( $wildcard_mime_types, $real_mime_types )
in~wp-includes/post.php
includes aforeach
loop that runs a regex on each uploaded media's mime type. The problem is that sometimes CP does not recognize the mime type, which results in the array,$real_mime_types
, including some entries offalse
. Whenpreg_match
is run in line 3019, everyfalse
value for$real
generates a warning.This PR addresses this issue by checking that every instance of
$real
has a truthy value.