Skip to content

Commit ce81a8f

Browse files
mraerinobradfitz
authored andcommitted
net/http: fix panic with If-None-Match value in http.ServeContent
Fixes #39817 Change-Id: I79f2ad7c836a8a46569f603aca583fdd526d22dc GitHub-Last-Rev: 5b88aad GitHub-Pull-Request: #39821 Reviewed-on: https://go-review.googlesource.com/c/go/+/239699 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 152ffca commit ce81a8f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/net/http/fs.go

+1
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ func checkIfNoneMatch(w ResponseWriter, r *Request) condResult {
413413
}
414414
if buf[0] == ',' {
415415
buf = buf[1:]
416+
continue
416417
}
417418
if buf[0] == '*' {
418419
return condFalse

src/net/http/fs_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,15 @@ func TestServeContent(t *testing.T) {
849849
wantStatus: 200,
850850
wantContentType: "text/css; charset=utf-8",
851851
},
852+
"if_none_match_malformed": {
853+
file: "testdata/style.css",
854+
serveETag: `"foo"`,
855+
reqHeader: map[string]string{
856+
"If-None-Match": `,`,
857+
},
858+
wantStatus: 200,
859+
wantContentType: "text/css; charset=utf-8",
860+
},
852861
"range_good": {
853862
file: "testdata/style.css",
854863
serveETag: `"A"`,

0 commit comments

Comments
 (0)