From: Daniel Martí Date: Tue, 25 Apr 2017 11:57:33 +0000 (+0100) Subject: html/template: use bytes.ContainsAny X-Git-Tag: go1.9beta1~476 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6049b1741d47b94a9c80dab7fc165d1eea5429bd;p=gostls13.git html/template: use bytes.ContainsAny It was added in Go 1.7. Also gofmt while at it. Change-Id: Idb65fb44e2f2a4365dceea3f833aeb51a8d12333 Reviewed-on: https://go-review.googlesource.com/41692 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/html/template/escape.go b/src/html/template/escape.go index 106067f792..3e8b455e33 100644 --- a/src/html/template/escape.go +++ b/src/html/template/escape.go @@ -64,7 +64,7 @@ var funcMap = template.FuncMap{ // predefinedEscapers contains template predefined escapers. var predefinedEscapers = map[string]bool{ - "html" : true, + "html": true, "urlquery": true, "js": true, } @@ -155,8 +155,8 @@ func (e *escaper) escapeAction(c context, n *parse.ActionNode) context { for _, ident := range allIdents(idNode.Args[0]) { if _, ok := predefinedEscapers[ident]; ok { return context{ - state: stateError, - err: errorf(ErrPredefinedEscaper, n, n.Line, "predefined escaper %q disallowed in template", ident), + state: stateError, + err: errorf(ErrPredefinedEscaper, n, n.Line, "predefined escaper %q disallowed in template", ident), } } } @@ -582,7 +582,7 @@ func (e *escaper) escapeText(c context, n *parse.TextNode) context { // the entire comment is considered to be a // LineTerminator for purposes of parsing by // the syntactic grammar." - if bytes.IndexAny(s[written:i1], "\n\r\u2028\u2029") != -1 { + if bytes.ContainsAny(s[written:i1], "\n\r\u2028\u2029") { b.WriteByte('\n') } else { b.WriteByte(' ') diff --git a/src/html/template/transition.go b/src/html/template/transition.go index 5d34d6947e..df7ac2289b 100644 --- a/src/html/template/transition.go +++ b/src/html/template/transition.go @@ -246,7 +246,7 @@ func tAttr(c context, s []byte) (context, int) { // tURL is the context transition function for the URL state. func tURL(c context, s []byte) (context, int) { - if bytes.IndexAny(s, "#?") >= 0 { + if bytes.ContainsAny(s, "#?") { c.urlPart = urlPartQueryOrFrag } else if len(s) != eatWhiteSpace(s, 0) && c.urlPart == urlPartNone { // HTML5 uses "Valid URL potentially surrounded by spaces" for