From 556a63de198b14df6054f3663b8eeb1b4bcf4763 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 30 Sep 2017 10:34:23 +0200 Subject: [PATCH] sftp: Return error when path starts with a tilde (~) --- internal/backend/sftp/config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/backend/sftp/config.go b/internal/backend/sftp/config.go index 708150206..90fe52c39 100644 --- a/internal/backend/sftp/config.go +++ b/internal/backend/sftp/config.go @@ -64,9 +64,15 @@ func ParseConfig(s string) (interface{}, error) { default: return nil, errors.New(`invalid format, does not start with "sftp:"`) } + + p := path.Clean(dir) + if strings.HasPrefix(p, "~") { + return nil, errors.Fatal("sftp path starts with the tilde (~) character, that fails for most sftp servers.\nUse a relative directory, most servers interpret this as relative to the user's home directory.") + } + return Config{ User: user, Host: host, - Path: path.Clean(dir), + Path: p, }, nil }