Commit 4646a330 authored by Samuel Tan's avatar Samuel Tan Committed by Brad Fitzpatrick

html/template: ensure that MIME type handling is case insensitive

Handle MIME types found in the type attribute of the script element
in a case insensitive way, as per Section 5.1 of RFC 2045.

Fixes #19968

Change-Id: Ie1416178c937dcf2c96bcec4191cebe7c3477af8
Reviewed-on: https://go-review.googlesource.com/40702Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 9248ff46
......@@ -1399,6 +1399,11 @@ func TestEscapeText(t *testing.T) {
`<script type="text/template">`,
context{state: stateText},
},
// covering issue 19968
{
`<script type="TEXT/JAVASCRIPT">`,
context{state: stateJS, element: elementScript},
},
{
`<script type="notjs">`,
context{state: stateText},
......
......@@ -372,7 +372,7 @@ func isJSType(mimeType string) bool {
// https://tools.ietf.org/html/rfc7231#section-3.1.1
// https://tools.ietf.org/html/rfc4329#section-3
// https://www.ietf.org/rfc/rfc4627.txt
mimeType = strings.ToLower(mimeType)
// discard parameters
if i := strings.Index(mimeType, ";"); i >= 0 {
mimeType = mimeType[:i]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment