mirror of
https://github.com/golang/go
synced 2024-11-22 00:24:41 -07:00
html/template: make doctype check case-insensitive
Fixes #3094. R=golang-dev, rsc, nigeltao CC=golang-dev https://golang.org/cl/5687065
This commit is contained in:
parent
19bab1dc78
commit
c05c3a9d11
@ -593,7 +593,7 @@ func (e *escaper) escapeText(c context, n *parse.TextNode) context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for j := i; j < end; j++ {
|
for j := i; j < end; j++ {
|
||||||
if s[j] == '<' && !bytes.HasPrefix(s[j:], doctypeBytes) {
|
if s[j] == '<' && !bytes.HasPrefix(bytes.ToUpper(s[j:]), doctypeBytes) {
|
||||||
b.Write(s[written:j])
|
b.Write(s[written:j])
|
||||||
b.WriteString("<")
|
b.WriteString("<")
|
||||||
written = j + 1
|
written = j + 1
|
||||||
|
@ -431,6 +431,11 @@ func TestEscape(t *testing.T) {
|
|||||||
"<!DOCTYPE html>Hello, World!",
|
"<!DOCTYPE html>Hello, World!",
|
||||||
"<!DOCTYPE html>Hello, World!",
|
"<!DOCTYPE html>Hello, World!",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"HTML doctype not case-insensitive",
|
||||||
|
"<!doCtYPE htMl>Hello, World!",
|
||||||
|
"<!doCtYPE htMl>Hello, World!",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"No doctype injection",
|
"No doctype injection",
|
||||||
`<!{{"DOCTYPE"}}`,
|
`<!{{"DOCTYPE"}}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user