From 4ce88d11312b763997bfc48af55b360219db9680 Mon Sep 17 00:00:00 2001 From: Sahil Prajapati Date: Tue, 19 May 2020 06:22:56 +0530 Subject: [PATCH 1/8] Add fonts .woff, .woff2, .eot and .ttf to mimetypes --- Lib/mimetypes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index e972ca2e291a0b..7ca948486b0b83 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -543,6 +543,10 @@ 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 From 621f88e92600fff57347a17a1cc3e5176f93a45c Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 19 May 2020 01:12:48 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst diff --git a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst new file mode 100644 index 00000000000000..fcff7964b8e005 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst @@ -0,0 +1 @@ +Add missing mimetypes for fonts \ No newline at end of file From 1a0e8ed1117e591bf6d870e0cd20b9690009b00a Mon Sep 17 00:00:00 2001 From: Sahil Prajapati Date: Tue, 19 May 2020 21:05:14 +0530 Subject: [PATCH 3/8] Sort .woff, .woff2, .eot, .ttf and .otf alphabetically --- Lib/mimetypes.py | 9 +++++---- Lib/test/test_mimetypes.py | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 7ca948486b0b83..835ce15874a8ee 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 9cac6ce0225e1c..03fe71efbfa43f 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -134,11 +134,16 @@ def test_init_reinitializes(self): 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') From 78dcd1185b1798d063a57012cf07ebe2fa8fb877 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:32:33 +0200 Subject: [PATCH 4/8] Add newline to fix lint, use gh issue number instead of bpo --- .../NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst | 1 - .../next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst create mode 100644 Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst diff --git a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst deleted file mode 100644 index fcff7964b8e005..00000000000000 --- a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.bpo-40675.FEjHJW.rst +++ /dev/null @@ -1 +0,0 @@ -Add missing mimetypes for fonts \ No newline at end of file diff --git a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst new file mode 100644 index 00000000000000..a76b64f47f7667 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst @@ -0,0 +1 @@ +Add missing mimetypes for fonts From fc668fd7015a197dde614db0053cdee1be03e0b4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:35:10 +0200 Subject: [PATCH 5/8] Remove duplicates added in merge conflict resolution --- Lib/mimetypes.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 04559e7c282f14..776fe6f76c66af 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -454,8 +454,6 @@ def _default_mime_types(): types_map = _types_map_default = { '.woff' : 'application/font-woff', '.woff2' : 'application/font-woff2', - '.js' : 'application/javascript', - '.mjs' : 'application/javascript', '.js' : 'text/javascript', '.mjs' : 'text/javascript', '.json' : 'application/json', From b08efee53f434b7c575cb8dfafe588d6bbc9183c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:17:38 +0200 Subject: [PATCH 6/8] Rename font MIME types to follow RFC 8081 https://www.iana.org/assignments/media-types/media-types.xhtml#font --- Doc/whatsnew/3.14.rst | 12 ++++++++++++ Lib/mimetypes.py | 8 ++++---- Lib/test/test_mimetypes.py | 8 ++++---- .../2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst | 3 ++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 80c1a93b95a6af..3817253c4f320a 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -352,6 +352,18 @@ json (Contributed by Trey Hunner in :gh:`122873`.) +mimetypes +--------- + +* Add :rfc:`8081` MIME types for fonts: + + * OpenType Layout (OTF) ``font/otf`` + * TrueType: ``font/ttf`` + * WOFF 1.0 ``font/woff`` + * WOFF 2.0 ``font/woff2`` + + (Contributed by Sahil Prajapati and Hugo van Kemenade in :gh:`84852`.) + operator -------- diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 776fe6f76c66af..c29367a9e77f41 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -452,8 +452,6 @@ 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' : 'text/javascript', '.mjs' : 'text/javascript', '.json' : 'application/json', @@ -492,8 +490,6 @@ 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', '.h5' : 'application/x-hdf5', @@ -547,6 +543,10 @@ def _default_mime_types(): '.aiff' : 'audio/x-aiff', '.ra' : 'audio/x-pn-realaudio', '.wav' : 'audio/x-wav', + '.otf' : 'font/otf', + '.ttf' : 'font/ttf', + '.woff' : 'font/woff', + '.woff2' : 'font/woff2', '.avif' : 'image/avif', '.bmp' : 'image/bmp', '.gif' : 'image/gif', diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index f08e9989eccf7c..b8fe3fac3c44bc 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -223,20 +223,20 @@ def test_guess_known_extensions(self): 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') self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3') + self.assertEqual(mimetypes.guess_extension('font/otf'), '.otf') + self.assertEqual(mimetypes.guess_extension('font/ttf'), '.ttf') + self.assertEqual(mimetypes.guess_extension('font/woff'), '.woff') + self.assertEqual(mimetypes.guess_extension('font/woff2'), '.woff2') self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif') self.assertEqual(mimetypes.guess_extension('image/webp'), '.webp') self.assertEqual(mimetypes.guess_extension('image/jpeg'), '.jpg') diff --git a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst index a76b64f47f7667..d45ef48ec5b462 100644 --- a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst +++ b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst @@ -1 +1,2 @@ -Add missing mimetypes for fonts +Add :rfc:`8081` MIME types for TrueType, OpenType Layout, WOFF 1.0 and 2.0 +fonts. Patch by Sahil Prajapati and Hugo van Kemenade. From d4cdfdc3fc9022af692af34247e29818a586effe Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:26:31 +0200 Subject: [PATCH 7/8] Update MS Embedded OpenType MIME type --- Doc/whatsnew/3.14.rst | 3 ++- Lib/mimetypes.py | 2 +- Lib/test/test_mimetypes.py | 2 +- .../Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 3817253c4f320a..a0915fd33444d5 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -355,8 +355,9 @@ json mimetypes --------- -* Add :rfc:`8081` MIME types for fonts: +* Add MS and :rfc:`8081` MIME types for fonts: + * Embedded OpenType: ``application/vnd.ms-fontobject`` * OpenType Layout (OTF) ``font/otf`` * TrueType: ``font/ttf`` * WOFF 1.0 ``font/woff`` diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index c29367a9e77f41..e3979c9493eac2 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -479,7 +479,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', + '.eot' : 'application/vnd.ms-fontobject', '.ppt' : 'application/vnd.ms-powerpoint', '.pot' : 'application/vnd.ms-powerpoint', '.ppa' : 'application/vnd.ms-powerpoint', diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index b8fe3fac3c44bc..cd3aa1e5367c49 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -227,7 +227,7 @@ def check_extensions(): 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-fontobject'), '.eot') self.assertEqual(mimetypes.guess_extension('application/vnd.ms-powerpoint'), '.ppt') self.assertEqual(mimetypes.guess_extension('application/x-texinfo'), '.texi') self.assertEqual(mimetypes.guess_extension('application/x-troff'), '.roff') diff --git a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst index d45ef48ec5b462..2581697591af62 100644 --- a/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst +++ b/Misc/NEWS.d/next/Library/2020-05-19-01-12-47.gh-issue-84852.FEjHJW.rst @@ -1,2 +1,2 @@ -Add :rfc:`8081` MIME types for TrueType, OpenType Layout, WOFF 1.0 and 2.0 -fonts. Patch by Sahil Prajapati and Hugo van Kemenade. +Add MIME types for MS Embedded OpenType, OpenType Layout, TrueType, +WOFF 1.0 and 2.0 fonts. Patch by Sahil Prajapati and Hugo van Kemenade. From 77a094a58335a596dc2a9c1674f3b420fa96765e Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 11 Nov 2024 23:27:16 +0200 Subject: [PATCH 8/8] Re-add newline --- Doc/whatsnew/3.14.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index ad0b3b1aee4613..9c032637d651ec 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -405,6 +405,7 @@ multiprocessing (Contributed by Roy Hyunjin Han for :gh:`103134`) + operator --------