From d29ed92dedb4fb4317d189aebd7cd0b4f2c00082 Mon Sep 17 00:00:00 2001 From: Samuel Tan Date: Wed, 28 Mar 2018 11:42:28 -0700 Subject: [PATCH] html/template: fix lint errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If56bd72917a9cbf5920ae8b5a36dc67f10959b94 Reviewed-on: https://go-review.googlesource.com/103175 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Daniel Martí --- src/html/template/url.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/html/template/url.go b/src/html/template/url.go index 69a6ff49b8..669600ef9a 100644 --- a/src/html/template/url.go +++ b/src/html/template/url.go @@ -37,15 +37,15 @@ func urlFilter(args ...interface{}) string { if t == contentTypeURL { return s } - if !isSafeUrl(s) { + if !isSafeURL(s) { return "#" + filterFailsafe } return s } -// isSafeUrl is true if s is a relative URL or if URL has a protocol in +// isSafeURL is true if s is a relative URL or if URL has a protocol in // (http, https, mailto). -func isSafeUrl(s string) bool { +func isSafeURL(s string) bool { if i := strings.IndexRune(s, ':'); i >= 0 && !strings.ContainsRune(s[:i], '/') { protocol := s[:i] @@ -79,15 +79,15 @@ func urlProcessor(norm bool, args ...interface{}) string { norm = true } var b bytes.Buffer - if processUrlOnto(s, norm, &b) { + if processURLOnto(s, norm, &b) { return b.String() } return s } -// processUrlOnto appends a normalized URL corresponding to its input to b +// processURLOnto appends a normalized URL corresponding to its input to b // and returns true if the appended content differs from s. -func processUrlOnto(s string, norm bool, b *bytes.Buffer) bool { +func processURLOnto(s string, norm bool, b *bytes.Buffer) bool { b.Grow(b.Cap() + len(s) + 16) written := 0 // The byte loop below assumes that all URLs use UTF-8 as the @@ -152,7 +152,7 @@ func srcsetFilterAndEscaper(args ...interface{}) string { // Normalizing gets rid of all HTML whitespace // which separate the image URL from its metadata. var b bytes.Buffer - if processUrlOnto(s, true, &b) { + if processURLOnto(s, true, &b) { s = b.String() } // Additionally, commas separate one source from another. @@ -173,43 +173,43 @@ func srcsetFilterAndEscaper(args ...interface{}) string { } // Derived from https://play.golang.org/p/Dhmj7FORT5 -const htmlSpaceAndAsciiAlnumBytes = "\x00\x36\x00\x00\x01\x00\xff\x03\xfe\xff\xff\x07\xfe\xff\xff\x07" +const htmlSpaceAndASCIIAlnumBytes = "\x00\x36\x00\x00\x01\x00\xff\x03\xfe\xff\xff\x07\xfe\xff\xff\x07" -// isHtmlSpace is true iff c is a whitespace character per +// isHTMLSpace is true iff c is a whitespace character per // https://infra.spec.whatwg.org/#ascii-whitespace -func isHtmlSpace(c byte) bool { - return (c <= 0x20) && 0 != (htmlSpaceAndAsciiAlnumBytes[c>>3]&(1<>3]&(1<>3]&(1<>3]&(1<