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

mime: ignore .js => text/plain in Windows registry #381

Merged
merged 1 commit into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/go1.19.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
</dd>
</dl><!-- io -->

<dl id="mime"><dt><a href="/pkg/mime/">mime</a></dt>
<dd>
<p><!-- CL 406894 -->
On Windows only, the mime package now ignores a registry entry
recording that the extension <code>.js</code> should have MIME
type <code>text/plain</code>. This is a common unintentional
misconfiguration on Windows systems. The effect is
that <code>.js</code> will have the default MIME
type <code>text/javascript; charset=utf-8</code>.
Applications that expect <code>text/plain</code> on Windows must
now explicitly call
<a href="/pkg/mime#AddExtensionType"><code>AddExtensionType</code></a>.
</p>
</dd>
</dl>

<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
<dd>
<p><!-- CL 386016 -->
Expand Down
11 changes: 11 additions & 0 deletions src/mime/type_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ func initMimeWindows() {
if err != nil {
continue
}

// There is a long-standing problem on Windows: the
// registry sometimes records that the ".js" extension
// should be "text/plain". See issue #32350. While
// normally local configuration should override
// defaults, this problem is common enough that we
// handle it here by ignoring that registry setting.
if name == ".js" && (v == "text/plain" || v == "text/plain; charset=utf-8") {
continue
}

setExtensionType(name, v)
}
}
Expand Down