[lxc-devel] [lxd/master] lxd/etag: Quote generated etag values
stgraber on Github
lxc-bot at linuxcontainers.org
Sun Mar 22 02:18:09 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 429 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200321/7b1fea91/attachment.bin>
-------------- next part --------------
From 1698da3234bb17a8fbe5f2bf5fa306a6a31b0f3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Sat, 21 Mar 2020 22:17:14 -0400
Subject: [PATCH] lxd/etag: Quote generated etag values
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
And accept both quoted and unquoted values in If-Match.
Closes #7068
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/response/response.go | 2 +-
lxd/util/http.go | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lxd/response/response.go b/lxd/response/response.go
index 128b1015d0..5270c489f3 100644
--- a/lxd/response/response.go
+++ b/lxd/response/response.go
@@ -74,7 +74,7 @@ func (r *syncResponse) Render(w http.ResponseWriter) error {
if r.etag != nil {
etag, err := util.EtagHash(r.etag)
if err == nil {
- w.Header().Set("ETag", etag)
+ w.Header().Set("ETag", fmt.Sprintf("\"%s\"", etag))
}
}
diff --git a/lxd/util/http.go b/lxd/util/http.go
index d2e16ea050..8b4d06c11e 100644
--- a/lxd/util/http.go
+++ b/lxd/util/http.go
@@ -64,6 +64,8 @@ func EtagCheck(r *http.Request, data interface{}) error {
return nil
}
+ match = strings.Trim(match, "\"")
+
hash, err := EtagHash(data)
if err != nil {
return err
More information about the lxc-devel
mailing list