From 419913a5dcfba77e41cbd4c2711248dfb349ae65 Mon Sep 17 00:00:00 2001 From: hcrosland Date: Fri, 26 May 2023 13:39:38 -0700 Subject: [PATCH 1/5] fix http regex string to add support for cas.v2 http requests --- server/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/http.go b/server/http.go index cc229d5ca..858af9205 100644 --- a/server/http.go +++ b/server/http.go @@ -27,7 +27,7 @@ import ( syncpool "github.com/mostynb/zstdpool-syncpool" ) -var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?(ac/|cas/)([a-f0-9]{64})$") +var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?(ac/|cas(.v2)?/)([a-f0-9]{64})$") var decoder, _ = zstd.NewReader(nil) // TODO: raise WithDecoderConcurrency ? From b0f7693f69c075397b4a51dd53223830f282b3f8 Mon Sep 17 00:00:00 2001 From: hcrosland Date: Fri, 26 May 2023 13:49:48 -0700 Subject: [PATCH 2/5] fix remainder of "cas" only references in http.go --- server/http.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/http.go b/server/http.go index 858af9205..edb77f682 100644 --- a/server/http.go +++ b/server/http.go @@ -100,14 +100,14 @@ func parseRequestURL(url string, validateAC bool) (kind cache.EntryKind, hash st parts := m[2:] if len(parts) != 2 { - err := fmt.Errorf("the path '%s' is invalid. expected (ac/|cas/)sha256", + err := fmt.Errorf("the path '%s' is invalid. expected (ac/|cas(.v2)?/)sha256", html.EscapeString(url)) return 0, "", "", err } - // The regex ensures that parts[0] can only be "ac/" or "cas/" + // The regex ensures that parts[0] can only be "ac/" or "cas(.v2)?/" hash = parts[1] - if parts[0] == "cas/" { + if parts[0] == "cas/" || parts[0] == "cas.v2/" { return cache.CAS, hash, instance, nil } From 3c60a631a5918c46d049cdf8a325500a7a9d7bc5 Mon Sep 17 00:00:00 2001 From: hcrosland Date: Fri, 26 May 2023 14:43:43 -0700 Subject: [PATCH 3/5] fix regex string --- server/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/http.go b/server/http.go index edb77f682..3e5aab0ef 100644 --- a/server/http.go +++ b/server/http.go @@ -27,7 +27,7 @@ import ( syncpool "github.com/mostynb/zstdpool-syncpool" ) -var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?(ac/|cas(.v2)?/)([a-f0-9]{64})$") +var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?(ac|cas(?:\\.v2)?/)([a-f0-9]{64})$") var decoder, _ = zstd.NewReader(nil) // TODO: raise WithDecoderConcurrency ? From 4b60a43098b2930eb5da337244a6d8b89489d15c Mon Sep 17 00:00:00 2001 From: hcrosland Date: Fri, 26 May 2023 14:52:23 -0700 Subject: [PATCH 4/5] fix ac matching in regex --- server/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/http.go b/server/http.go index 3e5aab0ef..cf992ef4b 100644 --- a/server/http.go +++ b/server/http.go @@ -27,7 +27,7 @@ import ( syncpool "github.com/mostynb/zstdpool-syncpool" ) -var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?(ac|cas(?:\\.v2)?/)([a-f0-9]{64})$") +var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?((?:ac|cas(?:\\.v2)?)/)([a-f0-9]{64})$") var decoder, _ = zstd.NewReader(nil) // TODO: raise WithDecoderConcurrency ? From 7b83c641adb5c929b3d92d793191073a21058542 Mon Sep 17 00:00:00 2001 From: hcrosland Date: Tue, 30 May 2023 15:58:08 -0700 Subject: [PATCH 5/5] use raw string for regex match --- server/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/http.go b/server/http.go index cf992ef4b..850d3f8ef 100644 --- a/server/http.go +++ b/server/http.go @@ -27,7 +27,7 @@ import ( syncpool "github.com/mostynb/zstdpool-syncpool" ) -var blobNameSHA256 = regexp.MustCompile("^/?(.*/)?((?:ac|cas(?:\\.v2)?)/)([a-f0-9]{64})$") +var blobNameSHA256 = regexp.MustCompile(`^/?(.*/)?((?:ac|cas(?:\.v2)?)/)([a-f0-9]{64})$`) var decoder, _ = zstd.NewReader(nil) // TODO: raise WithDecoderConcurrency ?