Browse Source

Merge pull request #1218 from StrangeWill/blank-name-fix

Fixes issue with LDAP inserting users with blank names.
for-closed-social
Lunny Xiao 9 years ago
parent
commit
2c4fb6e646
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      models/repo.go

+ 6
- 1
models/repo.go View File

@ -40,6 +40,7 @@ var (
ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
ErrMirrorNotExist = errors.New("Mirror does not exist")
ErrInvalidReference = errors.New("Invalid reference specified")
ErrNameEmpty = errors.New("Name is empty")
)
var (
@ -259,7 +260,11 @@ var (
// IsUsableName checks if name is reserved or pattern of name is not allowed.
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 {
if name == reservedNames[i] {
return ErrNameReserved{name}

Loading…
Cancel
Save