fspath: Stop empty strings being a valid path - fixes #4239

Before this change you could use "" as a valid remote, so `rclone lsf
""` would work. This was treated as the current directory.

This is unexpected and creates a footgun for scripting when an empty
variable is passed to rclone by accident.

This fix returns the error "can't use empty string as a path" instead
of allowing it.
This commit is contained in:
Nick Craig-Wood
2020-05-19 12:34:23 +01:00
parent ecdfd80459
commit eb6e9b194a
2 changed files with 8 additions and 3 deletions

View File

@@ -55,7 +55,7 @@ func TestParse(t *testing.T) {
in, wantConfigName, wantFsPath string
wantErr error
}{
{"", "", "", nil},
{"", "", "", errCantBeEmpty},
{":", "", "", errInvalidCharacters},
{"::", ":", "", errInvalidCharacters},
{":/:", "", "/:", errInvalidCharacters},
@@ -91,7 +91,7 @@ func TestSplit(t *testing.T) {
remote, wantParent, wantLeaf string
wantErr error
}{
{"", "", "", nil},
{"", "", "", errCantBeEmpty},
{"remote:", "remote:", "", nil},
{"remote:potato", "remote:", "potato", nil},