From 8363c9dd0f2161d4ca34f4b1e3eb5e02cf738a31 Mon Sep 17 00:00:00 2001 From: William Roush Date: Mon, 20 Apr 2015 01:28:19 -0400 Subject: [PATCH] Fixes issue with LDAP inserting users with blank names. --- models/repo.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/repo.go b/models/repo.go index cc4b53b0f29..f144be5a3fd 100644 --- a/models/repo.go +++ b/models/repo.go @@ -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}