]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: better comment in hasToken
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 29 May 2012 21:27:07 +0000 (14:27 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 29 May 2012 21:27:07 +0000 (14:27 -0700)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6249065

src/pkg/net/http/header.go

index d584c799f91c721c7e593269edcec9f1b63edbfa..0eca817d7a0b360843fb79c37ce48fe4fd6b68ad 100644 (file)
@@ -99,6 +99,11 @@ func hasToken(v, token string) bool {
        }
        for sp := 0; sp <= len(v)-len(token); sp++ {
                // Check that first character is good.
+               // The token is ASCII, so checking only a single byte
+               // is sufficient.  We skip this potential starting
+               // position if both the first byte and its potential
+               // ASCII uppercase equivalent (b|0x20) don't match.
+               // False positives ('^' => '~') are caught by EqualFold.
                if b := v[sp]; b != token[0] && b|0x20 != token[0] {
                        continue
                }