Added restrictions for separators

This commit is contained in:
joffrey-b 2026-04-21 11:45:50 +02:00
parent ebe01c2d43
commit bfbbd97324
2 changed files with 9 additions and 2 deletions

View file

@ -188,7 +188,14 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
}
cfg.defaultTheme = getenv(DEFAULT_THEME_ENV)
cfg.dateFormat = getenv(DATE_FORMAT_ENV)
rawDateFormat := getenv(DATE_FORMAT_ENV)
if rawDateFormat != "" {
validFormat := regexp.MustCompile(`^(DD|MM|YYYY)([-/.](DD|MM|YYYY)){2}$`)
if !validFormat.MatchString(rawDateFormat) {
return nil, fmt.Errorf("loadConfig: %s must use DD, MM, and YYYY tokens with a single / - or . separator (e.g. DD/MM/YYYY)", DATE_FORMAT_ENV)
}
}
cfg.dateFormat = rawDateFormat
cfg.configDir = getenv(CONFIG_DIR_ENV)
if cfg.configDir == "" {