]> Cypherpunks repositories - gostls13.git/commitdiff
html/template: ensure that MIME type handling is case insensitive
authorSamuel Tan <samueltan@google.com>
Fri, 14 Apr 2017 16:50:00 +0000 (09:50 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 20 Apr 2017 18:11:25 +0000 (18:11 +0000)
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/40702
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/html/template/escape_test.go
src/html/template/js.go

index 5dfb09b500967c2ffb7ecf0868ef7a3a580d8128..0a6a9e49c7c40a10b1f23cf23a222c908ed32d30 100644 (file)
@@ -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},
index 6434fa3be63217f90c4b0aae8dbc0ec6b523063b..239395f8d3a53bb26d911b3089a3df23ee716722 100644 (file)
@@ -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]