From 9e4ca6d1af64e72f60dc40d587f16c1b203357b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 7 Feb 2022 11:18:51 +0100 Subject: 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 --- request.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'request.go') 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() -- cgit v1.2.3