check for (some) bad data
This commit is contained in:
parent
7bf9f805c1
commit
5a7c186694
15
main.go
15
main.go
|
@ -48,6 +48,21 @@ func loadConfig() (err error) {
|
|||
|
||||
err = yaml.Unmarshal(configfile, &config)
|
||||
|
||||
// todo: check for bad data !!
|
||||
|
||||
var re = regexp.MustCompile(`(((ftp|http|https):\/\/)|(\/)|(..\/))(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?`)
|
||||
tocheck := [2]string{config.Panel.Host, config.Auth.GiteaURL}
|
||||
|
||||
for _, val := range tocheck {
|
||||
if len(re.FindStringIndex(val)) == 0 {
|
||||
log.Fatalf(`"%s" is not a valid url.`, val)
|
||||
}
|
||||
}
|
||||
|
||||
if config.Panel.Port > 65535 {
|
||||
log.Fatalf("port is too big (max 65535)")
|
||||
}
|
||||
|
||||
// init oauth bits
|
||||
redirecturi = fmt.Sprintf("%s/login/endpoint", config.Panel.Host)
|
||||
requesturl = fmt.Sprintf("%s/login/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code&state=STATE",
|
||||
|
|
Reference in New Issue