web: reject any whitespace-only input
This commit is contained in:
parent
e1c610caf9
commit
c792f7f570
3
web.go
3
web.go
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func(w http.ResponseWriter, req *http.Request) {
|
func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
@ -24,7 +25,7 @@ func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func
|
||||||
to := req.FormValue("to")
|
to := req.FormValue("to")
|
||||||
text := req.FormValue("text")
|
text := req.FormValue("text")
|
||||||
|
|
||||||
if text == "" {
|
if strings.TrimSpace(text) == "" {
|
||||||
tmpl.ExecuteTemplate(w, "index", indexPageData{Languages, from, to, text, ""})
|
tmpl.ExecuteTemplate(w, "index", indexPageData{Languages, from, to, text, ""})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue