minty-cafe/web/handler/form/settings.go

31 lines
530 B
Go
Raw Permalink Normal View History

2026-03-11 19:14:41 +00:00
package form
import (
"errors"
"net/http"
"strings"
)
type SettingsForm struct {
Homepage string
About string
Picture string
Email string
}
func (f *SettingsForm) Validate() error {
if strings.Contains(f.About, "<script") {
return errors.New("script tag is forbidden")
}
return nil
}
func NewSettingsForm(r *http.Request) *SettingsForm {
return &SettingsForm{
Homepage: r.FormValue("homepage"),
About: r.FormValue("about"),
Picture: r.FormValue("picture"),
Email: r.FormValue("email"),
}
}