From 1d8c6e314ba9d73ba55fff67e71afeb08bdad843 Mon Sep 17 00:00:00 2001 From: zhanglq Date: Thu, 2 Jul 2026 14:44:37 +0800 Subject: [PATCH] fix: use path.Clean instead of filepath.Clean for cross-platform URI canonicalization filepath.Clean converts forward slashes to backslashes on Windows, which breaks the AWS V4 signature calculation by corrupting the canonical URI. Use path.Clean which always uses forward slashes, matching the S3 API expectation. --- sign.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sign.go b/sign.go index 0ae3e2b..5187f3d 100644 --- a/sign.go +++ b/sign.go @@ -13,7 +13,7 @@ import ( "io/ioutil" "net/http" "net/url" - "path/filepath" + p "path" "sort" "strings" "time" @@ -68,7 +68,7 @@ func writeURI(w io.Writer, r *http.Request) { path = path[:len(path)-len(r.URL.RawQuery)-1] } slash := strings.HasSuffix(path, "/") - path = filepath.Clean(path) + path = p.Clean(path) if path != "/" && slash { path += "/" }