check honker name is plain

This commit is contained in:
Ted Unangst 2020-11-25 21:55:25 -05:00
parent 4bec62f23c
commit 7eaa6e3519
2 changed files with 8 additions and 2 deletions

View File

@ -55,6 +55,8 @@ import (
var savedassetparams = make(map[string]string)
var re_plainname = regexp.MustCompile("^[[:alnum:]]+$")
func getassetparam(file string) string {
if p, ok := savedassetparams[file]; ok {
return p
@ -309,8 +311,7 @@ func createuser(db *sql.DB, r *bufio.Reader) error {
if len(name) < 1 {
return fmt.Errorf("that's way too short")
}
re_name := regexp.MustCompile("^[[:alnum:]]+$")
if !re_name.MatchString(name) {
if !re_plainname.MatchString(name) {
return fmt.Errorf("alphanumeric only please")
}
if _, err := butwhatabout(name); err == nil {

5
web.go
View File

@ -1840,6 +1840,11 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
combos = " " + combos + " "
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
meta.Notes = strings.TrimSpace(r.FormValue("notes"))
mj, _ := jsonify(&meta)