~yerinalexey/gtranslate

c792f7f5703265db6075505dea0d3975e095be3c — Alexey Yerin a month ago e1c610c
web: reject any whitespace-only input
1 files changed, 2 insertions(+), 1 deletions(-)

M web.go
M web.go => web.go +2 -1
@@ 3,6 3,7 @@ package main
import (
	"html/template"
	"net/http"
	"strings"
)

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")
		text := req.FormValue("text")

		if text == "" {
		if strings.TrimSpace(text) == "" {
			tmpl.ExecuteTemplate(w, "index", indexPageData{Languages, from, to, text, ""})
			return
		}