check honker name is plain
This commit is contained in:
parent
4bec62f23c
commit
7eaa6e3519
5
util.go
5
util.go
|
@ -55,6 +55,8 @@ import (
|
||||||
|
|
||||||
var savedassetparams = make(map[string]string)
|
var savedassetparams = make(map[string]string)
|
||||||
|
|
||||||
|
var re_plainname = regexp.MustCompile("^[[:alnum:]]+$")
|
||||||
|
|
||||||
func getassetparam(file string) string {
|
func getassetparam(file string) string {
|
||||||
if p, ok := savedassetparams[file]; ok {
|
if p, ok := savedassetparams[file]; ok {
|
||||||
return p
|
return p
|
||||||
|
@ -309,8 +311,7 @@ func createuser(db *sql.DB, r *bufio.Reader) error {
|
||||||
if len(name) < 1 {
|
if len(name) < 1 {
|
||||||
return fmt.Errorf("that's way too short")
|
return fmt.Errorf("that's way too short")
|
||||||
}
|
}
|
||||||
re_name := regexp.MustCompile("^[[:alnum:]]+$")
|
if !re_plainname.MatchString(name) {
|
||||||
if !re_name.MatchString(name) {
|
|
||||||
return fmt.Errorf("alphanumeric only please")
|
return fmt.Errorf("alphanumeric only please")
|
||||||
}
|
}
|
||||||
if _, err := butwhatabout(name); err == nil {
|
if _, err := butwhatabout(name); err == nil {
|
||||||
|
|
5
web.go
5
web.go
|
@ -1840,6 +1840,11 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
|
||||||
combos = " " + combos + " "
|
combos = " " + combos + " "
|
||||||
honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0)
|
honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0)
|
||||||
|
|
||||||
|
if name != "" && !re_plainname.MatchString(name) {
|
||||||
|
http.Error(w, "please use a plainer name", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var meta HonkerMeta
|
var meta HonkerMeta
|
||||||
meta.Notes = strings.TrimSpace(r.FormValue("notes"))
|
meta.Notes = strings.TrimSpace(r.FormValue("notes"))
|
||||||
mj, _ := jsonify(&meta)
|
mj, _ := jsonify(&meta)
|
||||||
|
|
Loading…
Reference in New Issue