diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 7ca948486b0..835ce15874a 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -412,6 +412,8 @@ def _default_mime_types(): # Make sure the entry with the preferred file extension for a particular mime type # appears before any others of the same mimetype. types_map = _types_map_default = { + '.woff' : 'application/font-woff', + '.woff2' : 'application/font-woff2', '.js' : 'application/javascript', '.mjs' : 'application/javascript', '.json' : 'application/json', @@ -436,6 +438,7 @@ def _default_mime_types(): '.m3u8' : 'application/vnd.apple.mpegurl', '.xls' : 'application/vnd.ms-excel', '.xlb' : 'application/vnd.ms-excel', + '.eot' : 'application/vnd.ms-font', '.ppt' : 'application/vnd.ms-powerpoint', '.pot' : 'application/vnd.ms-powerpoint', '.ppa' : 'application/vnd.ms-powerpoint', @@ -446,6 +449,8 @@ def _default_mime_types(): '.cpio' : 'application/x-cpio', '.csh' : 'application/x-csh', '.dvi' : 'application/x-dvi', + '.otf' : 'application/x-font-opentype', + '.ttf' : 'application/x-font-ttf', '.gtar' : 'application/x-gtar', '.hdf' : 'application/x-hdf', '.latex' : 'application/x-latex', @@ -543,10 +548,6 @@ def _default_mime_types(): '.webm' : 'video/webm', '.avi' : 'video/x-msvideo', '.movie' : 'video/x-sgi-movie', - '.woff' : 'application/font-woff', - '.woff2' : 'application/font-woff2', - '.eot' : 'application/vnd.ms-font', - '.ttf' : 'application/x-font-ttf' } # These are non-standard types, commonly found in the wild. They will diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 9cac6ce0225..03fe71efbfa 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -134,11 +134,16 @@ class MimeTypesTestCase(unittest.TestCase): def test_preferred_extension(self): def check_extensions(): + self.assertEqual(mimetypes.guess_extension('application/font-woff'), '.woff') + self.assertEqual(mimetypes.guess_extension('application/font-woff2'), '.woff2') self.assertEqual(mimetypes.guess_extension('application/octet-stream'), '.bin') self.assertEqual(mimetypes.guess_extension('application/postscript'), '.ps') self.assertEqual(mimetypes.guess_extension('application/vnd.apple.mpegurl'), '.m3u') self.assertEqual(mimetypes.guess_extension('application/vnd.ms-excel'), '.xls') + self.assertEqual(mimetypes.guess_extension('application/vnd.ms-font'), '.eot') self.assertEqual(mimetypes.guess_extension('application/vnd.ms-powerpoint'), '.ppt') + self.assertEqual(mimetypes.guess_extension('application/x-font-opentype'), '.otf') + self.assertEqual(mimetypes.guess_extension('application/x-font-ttf'), '.ttf') self.assertEqual(mimetypes.guess_extension('application/x-texinfo'), '.texi') self.assertEqual(mimetypes.guess_extension('application/x-troff'), '.roff') self.assertEqual(mimetypes.guess_extension('application/xml'), '.xsl')