]> Sergey Matveev's repositories - btrtrc.git/blobdiff - webseed/request.go
Change default webseed path escaping to work for all S3-compatible providers
[btrtrc.git] / webseed / request.go
index a38e6372952357a7a8ea9d723bcafa84086bb887..e7c28155fbdc8eb76f9c930b0977eb049cdeb96f 100644 (file)
@@ -24,7 +24,12 @@ func EscapePath(pathComps []string) string {
 func defaultPathEscaper(pathComps []string) string {
        var ret []string
        for _, comp := range pathComps {
-               ret = append(ret, url.QueryEscape(comp))
+               esc := url.PathEscape(comp)
+               // S3 incorrectly escapes + in paths to spaces, so we add an extra encoding for that. This
+               // seems to be handled correctly regardless of whether an endpoint uses query or path
+               // escaping.
+               esc = strings.ReplaceAll(esc, "+", "%2B")
+               ret = append(ret, esc)
        }
        return path.Join(ret...)
 }