mirror of
https://github.com/go-gitea/gitea
synced 2024-11-17 15:31:06 +01:00
Fixes issue with LDAP inserting users with blank names.
This commit is contained in:
parent
3db0e7553e
commit
8363c9dd0f
1 changed files with 6 additions and 1 deletions
|
@ -40,6 +40,7 @@ var (
|
||||||
ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
|
ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
|
||||||
ErrMirrorNotExist = errors.New("Mirror does not exist")
|
ErrMirrorNotExist = errors.New("Mirror does not exist")
|
||||||
ErrInvalidReference = errors.New("Invalid reference specified")
|
ErrInvalidReference = errors.New("Invalid reference specified")
|
||||||
|
ErrNameEmpty = errors.New("Name is empty")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -259,7 +260,11 @@ var (
|
||||||
|
|
||||||
// IsUsableName checks if name is reserved or pattern of name is not allowed.
|
// IsUsableName checks if name is reserved or pattern of name is not allowed.
|
||||||
func IsUsableName(name string) error {
|
func IsUsableName(name string) error {
|
||||||
name = strings.ToLower(name)
|
name = strings.TrimSpace(strings.ToLower(name))
|
||||||
|
if utf8.RuneCountInString(name) == 0 {
|
||||||
|
return ErrNameEmpty
|
||||||
|
}
|
||||||
|
|
||||||
for i := range reservedNames {
|
for i := range reservedNames {
|
||||||
if name == reservedNames[i] {
|
if name == reservedNames[i] {
|
||||||
return ErrNameReserved{name}
|
return ErrNameReserved{name}
|
||||||
|
|
Loading…
Reference in a new issue