Skip to content

Commit

Permalink
Merge pull request #381 from golang/master
Browse files Browse the repository at this point in the history
mime: ignore .js => text/plain in Windows registry
  • Loading branch information
ferrmin authored May 29, 2022
2 parents 344b8ab + 52f68ef commit 5a391f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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

0 comments on commit 5a391f1

Please sign in to comment.