diff options
author | Samuel Tan <samueltan@google.com> | 2018-03-28 11:42:28 -0700 |
---|---|---|
committer | Daniel Martà <mvdan@mvdan.cc> | 2018-03-29 15:38:01 +0000 |
commit | d29ed92dedb4fb4317d189aebd7cd0b4f2c00082 (patch) | |
tree | 2a41c96a09c17037688c9eb24d65c36dbc75f4a7 /src/html | |
parent | 9364c13d09fb0df5a2f8cb4c86af9d37af857f20 (diff) | |
download | go-d29ed92dedb4fb4317d189aebd7cd0b4f2c00082.tar.gz go-d29ed92dedb4fb4317d189aebd7cd0b4f2c00082.zip |
html/template: fix lint errors
Change-Id: If56bd72917a9cbf5920ae8b5a36dc67f10959b94
Reviewed-on: https://go-review.googlesource.com/103175
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/template/url.go | 38 |
1 files 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<<uint(c&0x7))) +func isHTMLSpace(c byte) bool { + return (c <= 0x20) && 0 != (htmlSpaceAndASCIIAlnumBytes[c>>3]&(1<<uint(c&0x7))) } -func isHtmlSpaceOrAsciiAlnum(c byte) bool { - return (c < 0x80) && 0 != (htmlSpaceAndAsciiAlnumBytes[c>>3]&(1<<uint(c&0x7))) +func isHTMLSpaceOrAsciiAlnum(c byte) bool { + return (c < 0x80) && 0 != (htmlSpaceAndASCIIAlnumBytes[c>>3]&(1<<uint(c&0x7))) } func filterSrcsetElement(s string, left int, right int, b *bytes.Buffer) { start := left - for start < right && isHtmlSpace(s[start]) { - start += 1 + for start < right && isHTMLSpace(s[start]) { + start++ } end := right for i := start; i < right; i++ { - if isHtmlSpace(s[i]) { + if isHTMLSpace(s[i]) { end = i break } } - if url := s[start:end]; isSafeUrl(url) { + if url := s[start:end]; isSafeURL(url) { // If image metadata is only spaces or alnums then // we don't need to URL normalize it. metadataOk := true for i := end; i < right; i++ { - if !isHtmlSpaceOrAsciiAlnum(s[i]) { + if !isHTMLSpaceOrAsciiAlnum(s[i]) { metadataOk = false break } } if metadataOk { b.WriteString(s[left:start]) - processUrlOnto(url, true, b) + processURLOnto(url, true, b) b.WriteString(s[end:right]) return } |