From 28fe3db1fb0f89bcb55829ced33c1282f85f6e97 Mon Sep 17 00:00:00 2001 From: cchangwen <157893811+cchangwen@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:18:40 +0800 Subject: [PATCH] Also match weakly validated ETags (#28957) https://stackoverflow.com/questions/51973120/where-does-the-w-in-an-etag-appear-from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag# --------- Co-authored-by: delvh --- modules/httpcache/httpcache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index b57b3218322c7..40458dfc336e0 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -59,7 +59,7 @@ func checkIfNoneMatchIsValid(req *http.Request, etag string) bool { ifNoneMatch := req.Header.Get("If-None-Match") if len(ifNoneMatch) > 0 { for _, item := range strings.Split(ifNoneMatch, ",") { - item = strings.TrimSpace(item) + item = strings.TrimPrefix(strings.TrimSpace(item), "W/") // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#directives if item == etag { return true }