Merge pull request #4395 from reasonerjt/fix-project-length-limit

Extend the length of project name in request validation
This commit is contained in:
Daniel Jiang 2018-03-12 19:20:21 +08:00 committed by GitHub
commit 230bb89d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,7 @@ type ProjectAPI struct {
project *models.Project
}
const projectNameMaxLen int = 30
const projectNameMaxLen int = 255
const projectNameMinLen int = 2
const restrictedNameChars = `[a-z0-9]+(?:[._-][a-z0-9]+)*`
@ -491,7 +491,7 @@ func (p *ProjectAPI) Logs() {
func validateProjectReq(req *models.ProjectRequest) error {
pn := req.Name
if isIllegalLength(req.Name, projectNameMinLen, projectNameMaxLen) {
return fmt.Errorf("Project name is illegal in length. (greater than 2 or less than 30)")
return fmt.Errorf("Project name is illegal in length. (greater than %d or less than %d)", projectNameMaxLen, projectNameMinLen)
}
validProjectName := regexp.MustCompile(`^` + restrictedNameChars + `$`)
legal := validProjectName.MatchString(pn)