From 4e952af6143cc1527cf25e02746ff738e08f7e74 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 12 Oct 2015 17:54:09 +0100 Subject: [PATCH] Allow spaces in remotes and check remote names for validity at creation time - fixes #171 --- fs/config.go | 3 +++ fs/fs.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/config.go b/fs/config.go index 28773c7f8..aa0800aff 100644 --- a/fs/config.go +++ b/fs/config.go @@ -498,11 +498,14 @@ func EditConfig() { for { fmt.Printf("name> ") name := ReadLine() + parts := matcher.FindStringSubmatch(name + ":") switch { case name == "": fmt.Printf("Can't use empty name\n") case isDriveLetter(name): fmt.Printf("Can't use %q as it can be confused a drive letter\n", name) + case len(parts) != 3 || parts[2] != "": + fmt.Printf("Can't use %q as it has invalid characters in it %v\n", name, parts) default: NewRemote(name) break nameLoop diff --git a/fs/fs.go b/fs/fs.go index d8573f778..639b0ba34 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -284,7 +284,7 @@ func Find(name string) (*Info, error) { } // Pattern to match an rclone url -var matcher = regexp.MustCompile(`^([\w_-]+):(.*)$`) +var matcher = regexp.MustCompile(`^([\w_ -]+):(.*)$`) // NewFs makes a new Fs object from the path //