]> Cypherpunks.ru repositories - gostls13.git/commitdiff
net/http: fix panic with If-None-Match value in http.ServeContent
authorMarcus Weiner <marcus.weiner@gmail.com>
Wed, 24 Jun 2020 15:24:56 +0000 (15:24 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 29 Jun 2020 14:56:46 +0000 (14:56 +0000)
Fixes #39817

Change-Id: I79f2ad7c836a8a46569f603aca583fdd526d22dc
GitHub-Last-Rev: 5b88aada219aaa2af0c7e1969ed6fa646117d9da
GitHub-Pull-Request: golang/go#39821
Reviewed-on: https://go-review.googlesource.com/c/go/+/239699
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/fs.go
src/net/http/fs_test.go

index 07d15b07e92f11517a280fbc73d26db42fdeb191..922706ada1481567045a8ae3dd3a8494a7daf12f 100644 (file)
@@ -413,6 +413,7 @@ func checkIfNoneMatch(w ResponseWriter, r *Request) condResult {
                }
                if buf[0] == ',' {
                        buf = buf[1:]
+                       continue
                }
                if buf[0] == '*' {
                        return condFalse
index 435e34be3af08082716a5dc7a5191adc9837d245..c082ceee71b30af65e573794df79c42b24476095 100644 (file)
@@ -849,6 +849,15 @@ func TestServeContent(t *testing.T) {
                        wantStatus:      200,
                        wantContentType: "text/css; charset=utf-8",
                },
+               "if_none_match_malformed": {
+                       file:      "testdata/style.css",
+                       serveETag: `"foo"`,
+                       reqHeader: map[string]string{
+                               "If-None-Match": `,`,
+                       },
+                       wantStatus:      200,
+                       wantContentType: "text/css; charset=utf-8",
+               },
                "range_good": {
                        file:      "testdata/style.css",
                        serveETag: `"A"`,