fix: check length of site name and site description

This commit is contained in:
hexxa 2022-04-16 11:12:01 +08:00 committed by Hexxa
parent 191146ac7c
commit c202911fc8
2 changed files with 5 additions and 2 deletions

View file

@ -83,8 +83,10 @@ func (h *SettingsSvc) SetClientCfg(c *gin.Context) {
}
func validateClientCfg(cfg *db.ClientConfig) error {
if cfg.SiteName == "" {
return errors.New("site name is empty")
if len(cfg.SiteName) == 0 || len(cfg.SiteName) >= 12 {
return errors.New("site name is too short or too long")
} else if len(cfg.SiteDesc) >= 64 {
return errors.New("site description is too short or too long")
}
return nil
}