From c5acb1015183507a2575934dcfef7d513fff26e0 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Thu, 19 Jan 2023 21:38:24 +0100 Subject: [PATCH] fspath: allow the symbols at and plus in remote names - fixes #6710 --- docs/content/docs.md | 2 +- fs/config/ui_test.go | 2 +- fs/fspath/path.go | 6 +++--- fs/fspath/path_test.go | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/content/docs.md b/docs/content/docs.md index 8c9cae769..b00177c2b 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -338,7 +338,7 @@ Will get their own names ### Valid remote names Remote names are case sensitive, and must adhere to the following rules: - - May contain number, letter, `_`, `-`, `.` and space. + - May contain number, letter, `_`, `-`, `.`, `+`, `@` and space. - May not start with `-` or space. - May not end with space. diff --git a/fs/config/ui_test.go b/fs/config/ui_test.go index 0756481d1..6a4d5aee0 100644 --- a/fs/config/ui_test.go +++ b/fs/config/ui_test.go @@ -183,7 +183,7 @@ func TestNewRemoteName(t *testing.T) { config.ReadLine = makeReadLine([]string{ "test", // already exists "", // empty string not allowed - "bad@characters", // bad characters + "bad^characters", // bad characters "newname", // OK }) diff --git a/fs/fspath/path.go b/fs/fspath/path.go index 5a6775207..09e71d08e 100644 --- a/fs/fspath/path.go +++ b/fs/fspath/path.go @@ -13,12 +13,12 @@ import ( ) const ( - configNameRe = `[\w\p{L}\p{N}.]+(?:[ -]+[\w\p{L}\p{N}.-]+)*` // May contain Unicode numbers and letters, as well as `_`, `-`, `.` and space, but not start with `-` (it complicates usage, see #4261) or space, and not end with space - illegalPartOfConfigNameRe = `^[ -]+|[^\w\p{L}\p{N}. -]+|[ ]+$` + configNameRe = `[\w\p{L}\p{N}.+@]+(?:[ -]+[\w\p{L}\p{N}.+@-]+)*` // May contain Unicode numbers and letters, as well as `_` (covered by \w), `-`, `.`, `+`, `@` and space, but not start with `-` (it complicates usage, see #4261) or space, and not end with space + illegalPartOfConfigNameRe = `^[ -]+|[^\w\p{L}\p{N}.+@ -]+|[ ]+$` ) var ( - errInvalidCharacters = errors.New("config name contains invalid characters - may only contain numbers, letters, `_`, `-`, `.` and space, while not start with `-` or space, and not end with space") + errInvalidCharacters = errors.New("config name contains invalid characters - may only contain numbers, letters, `_`, `-`, `.`, `+`, `@` and space, while not start with `-` or space, and not end with space") errCantBeEmpty = errors.New("can't use empty string as a path") errBadConfigParam = errors.New("config parameters may only contain `0-9`, `A-Z`, `a-z` and `_`") errEmptyConfigParam = errors.New("config parameters can't be empty") diff --git a/fs/fspath/path_test.go b/fs/fspath/path_test.go index d1828c102..07becd876 100644 --- a/fs/fspath/path_test.go +++ b/fs/fspath/path_test.go @@ -41,6 +41,8 @@ func TestCheckConfigName(t *testing.T) { {"..", nil, ".."}, {".r.e.m.o.t.e.", nil, ".r.e.m.o.t.e."}, {"rem ote", nil, "rem ote"}, + {"user@example.com", nil, "user@example.com"}, + {"user+junkmail@example.com", nil, "user+junkmail@example.com"}, {"blåbær", nil, "blåbær"}, {"chữ Quốc ngữ", nil, "chữ Quốc ngữ"}, {"remote ", errInvalidCharacters, "remote_"}, @@ -68,6 +70,8 @@ func TestCheckRemoteName(t *testing.T) { {".r.e.m.o.t.e.:", nil}, {"-r-emote-:", errInvalidCharacters}, {"rem ote:", nil}, + {"user@example.com:", nil}, + {"user+junkmail@example.com:", nil}, {"blåbær:", nil}, {"chữ Quốc ngữ:", nil}, {"remote :", errInvalidCharacters},