fspath: allow the symbols at and plus in remote names - fixes #6710

This commit is contained in:
albertony 2023-01-19 21:38:24 +01:00
parent 8c8ee9905c
commit c5acb10151
4 changed files with 9 additions and 5 deletions

View File

@ -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.

View File

@ -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
})

View File

@ -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")

View File

@ -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},