Commit 2c1888bf authored by Daniel Martí's avatar Daniel Martí

net/http: fix ineffective break in etag scanning

In particular, this lead to the code accepting invalid ETags as long as
they finished with a '"'.

Also remove a duplicate test case.

Change-Id: Id59db3ebc4e4969562f891faef29111e77ee0e65
Reviewed-on: https://go-review.googlesource.com/39690
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0bae9b08
......@@ -315,7 +315,7 @@ func scanETag(s string) (etag string, remain string) {
case c == '"':
return string(s[:i+1]), s[i+1:]
default:
break
return "", ""
}
}
return "", ""
......
......@@ -1264,10 +1264,10 @@ func Test_scanETag(t *testing.T) {
{`"etag-2"`, `"etag-2"`, ""},
{`"etag-1", "etag-2"`, `"etag-1"`, `, "etag-2"`},
{"", "", ""},
{"", "", ""},
{"W/", "", ""},
{`W/"truc`, "", ""},
{`w/"case-sensitive"`, "", ""},
{`"spaced etag"`, "", ""},
}
for _, test := range tests {
etag, remain := ExportScanETag(test.in)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment