Skip to content
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

gh-92626: Correct JavaScript MIME types + extensions per RFC 9239 #92627

Closed
wants to merge 3 commits into from

Conversation

mathiasbynens
Copy link

@mathiasbynens mathiasbynens commented May 10, 2022

This patch updates the MIME type configuration per RFC 9239.
https://www.rfc-editor.org/rfc/rfc9239

First, the recommended MIME type is now text/javascript:

The most widely supported media type in use is text/javascript; all
others are considered historical and obsolete aliases of text/javascript.

Second, the .mjs extension is now explicitly registered:

The .mjs file extension signals that the file represents a JavaScript
module. Execution environments that rely on file extensions to
determine how to process inputs parse .mjs files using the Module
grammar of [ECMA-262].

cpython already had an entry for .mjs (great!), but it was using the obsolete
MIME type.

IANA template: https://www.iana.org/assignments/media-types/text/javascript

Issue: #92626

This patch updates the MIME type configuration per RFC 9239.
https://www.rfc-editor.org/rfc/rfc9239

First, the recommended MIME type is now `text/javascript`:

> The most widely supported media type in use is `text/javascript`; all
> others are considered historical and obsolete aliases of `text/javascript`.

Second, the `.mjs` extension is now explicitly registered:

> The `.mjs` file extension signals that the file represents a JavaScript
> module. Execution environments that rely on file extensions to
> determine how to process inputs parse `.mjs` files using the Module
> grammar of [ECMA-262].

IANA template: https://www.iana.org/assignments/media-types/text/javascript
@mathiasbynens mathiasbynens requested a review from a team as a code owner May 10, 2022 14:50
@cpython-cla-bot
Copy link

cpython-cla-bot bot commented May 10, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Every change to Python requires a NEWS entry.

Please, add it using the blurb_it Web app or the blurb command-line tool.

@arhadthedev
Copy link
Member

RFC: 9239
Published: May 2022

6.1.Common JavaScript Media Types
6.1.1. text/javascript

🎉🎉🎉 Finally encoding-aware human-readable text is treated as such (text/*) instead of binary blobs (application/*).

text

Text-only data including any human-readable content, source code, or textual data such as comma-separated value (CSV) formatted data.

application

Any kind of binary data that doesn't fall explicitly into one of the other types; either data that will be executed or interpreted in some way or binary data that requires a specific application or category of application to use. Generic binary data (or binary data whose true type is unknown) is application/octet-stream. Other common examples include application/pdf, application/pkcs8, and application/zip.

-- https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types

@AA-Turner AA-Turner added stdlib Python modules in the Lib dir topic-email labels May 27, 2022
@AA-Turner
Copy link
Member

Lib/test/mime.types should maybe be updated, although it seems that file hasn't been substantively updated since 2011:

# text/javascript obsoleted by application/javascript

Also:

AddType application/javascript js
AddType application/wasm wasm
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html application/javascript application/wasm

A

@AA-Turner
Copy link
Member

@warsaw would we backport something like this? I'm unsure if it would count as a bugfix.

A

@arhadthedev
Copy link
Member

It would be great to have this PR merged since it brings stuff to the latest RFC.

@encukou
Copy link
Member

encukou commented Mar 26, 2024

This was changed in #97934. Apologies for forgetting this PR.

@encukou encukou closed this Mar 26, 2024
@mathiasbynens mathiasbynens deleted the rfc-9239 branch March 26, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stdlib Python modules in the Lib dir topic-email
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants