mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-03 06:28:06 +01:00
Merge pull request #4395 from reasonerjt/fix-project-length-limit
Extend the length of project name in request validation
This commit is contained in:
commit
230bb89d1e
@ -42,7 +42,7 @@ type ProjectAPI struct {
|
|||||||
project *models.Project
|
project *models.Project
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectNameMaxLen int = 30
|
const projectNameMaxLen int = 255
|
||||||
const projectNameMinLen int = 2
|
const projectNameMinLen int = 2
|
||||||
const restrictedNameChars = `[a-z0-9]+(?:[._-][a-z0-9]+)*`
|
const restrictedNameChars = `[a-z0-9]+(?:[._-][a-z0-9]+)*`
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ func (p *ProjectAPI) Logs() {
|
|||||||
func validateProjectReq(req *models.ProjectRequest) error {
|
func validateProjectReq(req *models.ProjectRequest) error {
|
||||||
pn := req.Name
|
pn := req.Name
|
||||||
if isIllegalLength(req.Name, projectNameMinLen, projectNameMaxLen) {
|
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 + `$`)
|
validProjectName := regexp.MustCompile(`^` + restrictedNameChars + `$`)
|
||||||
legal := validProjectName.MatchString(pn)
|
legal := validProjectName.MatchString(pn)
|
||||||
|
Loading…
Reference in New Issue
Block a user