mirror of
https://github.com/rclone/rclone.git
synced 2025-02-01 19:20:18 +01:00
lib/bucket: fix tidying of // in object keys #5858
Before this change, bucket.Join would tidy up object keys by removing repeated / in them. This means we can't access objects with // in them which is valid for object keys (but not for file system paths). This could have consequences for users who are relying on rclone to fix improper paths for them.
This commit is contained in:
parent
b4990cd858
commit
fe19184084
@ -31,7 +31,9 @@ func Split(absPath string) (bucket, bucketPath string) {
|
|||||||
|
|
||||||
// Join path1 and path2
|
// Join path1 and path2
|
||||||
//
|
//
|
||||||
// Like path.Join but does not clean the path - useful to preserve trailing /
|
// Like path.Join but does not clean the path - useful to preserve trailing /.
|
||||||
|
//
|
||||||
|
// It also does not clean multiple // in the path.
|
||||||
func Join(path1, path2 string) string {
|
func Join(path1, path2 string) string {
|
||||||
if path1 == "" {
|
if path1 == "" {
|
||||||
return path2
|
return path2
|
||||||
@ -39,7 +41,7 @@ func Join(path1, path2 string) string {
|
|||||||
if path2 == "" {
|
if path2 == "" {
|
||||||
return path1
|
return path1
|
||||||
}
|
}
|
||||||
return strings.TrimSuffix(path1, "/") + "/" + strings.TrimPrefix(path2, "/")
|
return path1 + "/" + path2
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAllSlashes returns true if s is all / characters.
|
// IsAllSlashes returns true if s is all / characters.
|
||||||
|
@ -34,10 +34,10 @@ func TestJoin(t *testing.T) {
|
|||||||
{in1: "in1", in2: "", want: "in1"},
|
{in1: "in1", in2: "", want: "in1"},
|
||||||
{in1: "", in2: "in2", want: "in2"},
|
{in1: "", in2: "in2", want: "in2"},
|
||||||
{in1: "in1", in2: "in2", want: "in1/in2"},
|
{in1: "in1", in2: "in2", want: "in1/in2"},
|
||||||
{in1: "in1/", in2: "in2", want: "in1/in2"},
|
{in1: "in1/", in2: "in2", want: "in1//in2"},
|
||||||
{in1: "in1", in2: "/in2", want: "in1/in2"},
|
{in1: "in1", in2: "/in2", want: "in1//in2"},
|
||||||
{in1: "in1", in2: "in2/", want: "in1/in2/"},
|
{in1: "in1", in2: "in2/", want: "in1/in2/"},
|
||||||
{in1: "/in1", in2: "/in2", want: "/in1/in2"},
|
{in1: "/in1", in2: "/in2", want: "/in1//in2"},
|
||||||
{in1: "/in1", in2: "../in2", want: "/in1/../in2"},
|
{in1: "/in1", in2: "../in2", want: "/in1/../in2"},
|
||||||
} {
|
} {
|
||||||
got := Join(test.in1, test.in2)
|
got := Join(test.in1, test.in2)
|
||||||
|
Loading…
Reference in New Issue
Block a user