Description
Symfony version(s) affected: symfony/mime (all versions)
Description
The class Symfony\Component\Mime\MimeTypes
contains a mapping from mime type to possible extensions. This mapping is derived from https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types. For image/jpeg
and image/pjpeg
the extensions are 'jpeg', 'jpg', 'jpe'
.
The method guessExtension()
of Symfony\Component\HttpFoundation\File\File
uses this map to find extensions for mime types. For image/jpeg
, it returns jpeg
because that is the first one in the list, even though jpg
is a much more common extension.
How to reproduce
<?php
$file = new Symfony\Component\HttpFoundation\File\File('somefile.jpg');
$ext = $file->guessExtension();
// $ext is 'jpeg'
?>
Possible Solution
I propose that update_mime_types.php
is updated such that it writes 'jpg', 'jpeg', 'jpe'
to MimeTypes.php
to have guessExtension()
return jpg
instead of jpeg
.