aboutsummaryrefslogtreecommitdiff
path: root/request.go
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@sap.com>2022-02-07 11:18:51 +0100
committerStefan Majewsky <stefan.majewsky@sap.com>2022-02-07 11:18:51 +0100
commit9e4ca6d1af64e72f60dc40d587f16c1b203357b4 (patch)
treea8297deca73f723e6921dc5bdde8ebcb66f24c1e /request.go
parent79df56a219c657d51327ca95a1696cd329629665 (diff)
downloadgo-schwift-9e4ca6d1af64e72f60dc40d587f16c1b203357b4.tar.gz
do not mangle non-standard object paths
If the object path contains multiple slashes back-to-back, these used to be wrongly merged by net.url.URL.String(). For example, account = "AUTH_aaa" container = "ccc" object = "foo///bar" would become something like https://swift.example.com/v1/AUTH_aaa/ccc/foo/bar With this change, we produce a more correct URL: https://swift.example.com/v1/AUTH_aaa/ccc/foo%2f%2f%2fbar
Diffstat (limited to 'request.go')
-rw-r--r--request.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/request.go b/request.go
index 0277f9a..266bee2 100644
--- a/request.go
+++ b/request.go
@@ -98,7 +98,9 @@ func (r Request) URL(backend Backend, values url.Values) (string, error) {
if strings.Contains(r.ContainerName, "/") {
return "", ErrMalformedContainerName
}
- uri.Path += r.ContainerName + "/" + r.ObjectName
+ // Encode path so that double slashes are encoded and handled correct by backend server
+ uri.RawPath = uri.Path + r.ContainerName + "/" + url.PathEscape(r.ObjectName)
+ uri.Path = uri.Path + r.ContainerName + "/" + r.ObjectName
}
uri.RawQuery = values.Encode()