diff options
author | Marcus Weiner <marcus.weiner@gmail.com> | 2020-06-24 15:24:56 +0000 |
---|---|---|
committer | Dmitri Shuralyov <dmitshur@golang.org> | 2020-07-13 18:33:23 +0000 |
commit | e19af0f1447e0f99688949c68cd8c39d188f699c (patch) | |
tree | a1c7363437f2d7cd76308901dd936d3eb8bcd3eb | |
parent | 3c1722cf30d1edc6756022c7a12efffabcfb098a (diff) | |
download | go-e19af0f1447e0f99688949c68cd8c39d188f699c.tar.gz go-e19af0f1447e0f99688949c68cd8c39d188f699c.zip |
[release-branch.go1.13] net/http: fix panic with If-None-Match value in http.ServeContent
Updates #39817.
Fixes #39925.
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>
(cherry picked from commit ce81a8f5e4f6c33036aa0777fabc47eeeab468dc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/242077
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Marcus Weiner <marcus.weiner@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
-rw-r--r-- | src/net/http/fs.go | 1 | ||||
-rw-r--r-- | src/net/http/fs_test.go | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/net/http/fs.go b/src/net/http/fs.go index 41d46dced2..ac4ed23e71 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -408,6 +408,7 @@ func checkIfNoneMatch(w ResponseWriter, r *Request) condResult { } if buf[0] == ',' { buf = buf[1:] + continue } if buf[0] == '*' { return condFalse diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go index 762e88b05f..f3c240fe7e 100644 --- a/src/net/http/fs_test.go +++ b/src/net/http/fs_test.go @@ -837,6 +837,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"`, |