more relaxed name check for honker

This commit is contained in:
Ted Unangst 2021-04-02 19:59:01 -04:00
parent b4e6116b11
commit ca78de15cc
2 changed files with 4 additions and 3 deletions

View File

@ -55,7 +55,7 @@ import (
var savedassetparams = make(map[string]string) var savedassetparams = make(map[string]string)
var re_plainname = regexp.MustCompile("^[[:alnum:]]+$") 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 {

5
web.go
View File

@ -1851,7 +1851,8 @@ 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) { re_namecheck := regexp.MustCompile("[[:alnum:]_.-]+")
if name != "" && !re_namecheck.MatchString(name) {
http.Error(w, "please use a plainer name", http.StatusInternalServerError) http.Error(w, "please use a plainer name", http.StatusInternalServerError)
return return
} }
@ -1897,7 +1898,7 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
if url[0] == '#' { if url[0] == '#' {
flavor = "peep" flavor = "peep"
if name == "" { if name == "" {
name = url name = url[1:]
} }
_, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, url, mj) _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos, url, mj)
if err != nil { if err != nil {