aboutsummaryrefslogtreecommitdiffstats
path: root/modules/httpcache
diff options
context:
space:
mode:
authorcchangwen <157893811+cchangwen@users.noreply.github.com>2024-01-30 00:18:40 +0800
committerGitHub <noreply@github.com>2024-01-29 16:18:40 +0000
commit28fe3db1fb0f89bcb55829ced33c1282f85f6e97 (patch)
tree696158dfebce1495340f6b4f553b8cf8811c09d9 /modules/httpcache
parent2a50d780f93957223da9494c61bb3181ffa7ff65 (diff)
downloadgitea-28fe3db1fb0f89bcb55829ced33c1282f85f6e97.tar.gz
gitea-28fe3db1fb0f89bcb55829ced33c1282f85f6e97.zip
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 <dev.lh@web.de>
Diffstat (limited to 'modules/httpcache')
-rw-r--r--modules/httpcache/httpcache.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go
index b57b321832..40458dfc33 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
}