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.
This commit is contained in:
zhanglq
2026-07-02 14:55:57 +08:00
parent 57fa0ece6f
commit 1d8c6e314b
+2 -2
View File
@@ -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 += "/"
}