30 lines
530 B
Go
30 lines
530 B
Go
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"),
|
|
}
|
|
}
|