allow spaces in greenzone

This commit is contained in:
Joerg Lehmann 2022-06-03 18:13:36 +02:00
parent 8e465698ad
commit 8232be9c01
2 changed files with 3 additions and 2 deletions

View File

@ -10,7 +10,7 @@ function validate(what, text) {
} else if (what == 'email') {
var re = /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([,.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$/;
} else if (what == 'greenzone') {
var re = /^$|^[0-9]+\.[0-9]+,[0-9]+\.[0-9]+,[0-9]+\.[0-9]+,[0-9]+\.[0-9]+$/;
var re = /^ *$|^[0-9]+\.[0-9]+,[0-9]+\.[0-9]+,[0-9]+\.[0-9]+,[0-9]+\.[0-9]+$/;
}
return re.test(text);

View File

@ -5,6 +5,7 @@ import (
"log"
"net/http"
"regexp"
"strings"
)
// tracker handler
@ -124,7 +125,7 @@ func save_tracker_settingsHandler(response http.ResponseWriter, request *http.Re
fmt.Fprintf(response, "{ \"rc\": 16, \"msg\": \"greenzone must be specified in URL\" }")
return
}
mygreenzone := greenzone[0]
mygreenzone := strings.ReplaceAll(greenzone[0]," ","")
match3, _ := regexp.MatchString(`^$|^[0-9]+\.[0-9]+,[0-9]+\.[0-9]+,[0-9]+\.[0-9]+,[0-9]+\.[0-9]+$`, mygreenzone)
if !(match3) {