[6.x] validateDimensions() handle image/svg MIME #30204
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added
image/svg
MIME support tovalidateDimensions()
function.During the image dimensions validation there is a
getMimeType()
function called on aIlluminate\Http\UploadedFile
class (inherited fromSymfony\Component\HttpFoundation\File\UploadedFile
<-Symfony\Component\HttpFoundation\File\File
) class.It utilizes the
Symfony\Component\Mime\MimeTypes
which calls theguessMimeType()
on theSymfony\Component\Mime\FileinfoMimeTypeGuesser
class.At this point
finfo
class is used:I've found it can return two different values for SVG files:
image/svg+xml
andimage/svg
.I didn't find any documentation about this behavior (only a magic test: https://github.com/php/php-src/blob/master/ext/fileinfo/tests/magic), but it can be easily reproduced via this Gist:
https://gist.github.com/0xB4LINT/0d90ddaa02c91147635667b2a8b90f9b
The only difference between the source files is the lack of
<?xml ... ?>
row.By the W3's SVG standard document there are more valid document structures defined:
<?xml ... ?><svg ...
or<svg xmlns="...
Extends #30009: replaced
getClientMimeType()
withgetMimeType()
, but doesn't handle theimage/svg
MIME.