aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-04-15 03:57:53 +0200
committerPřemysl Janouch <p@janouch.name>2019-04-15 03:57:53 +0200
commit82c6c34ea58ec775a799533c4ce6f497b53d11bf (patch)
treea02db1d08ce3746fdd30dede7260d77c435882a9
parent5b7113905ecdb1646ead78a05b1e10c5ebee9b6f (diff)
downloadsklad-82c6c34ea58ec775a799533c4ce6f497b53d11bf.tar.gz
sklad-82c6c34ea58ec775a799533c4ce6f497b53d11bf.tar.xz
sklad-82c6c34ea58ec775a799533c4ce6f497b53d11bf.zip
sklad: trim spaces from user-supplied attributes
-rw-r--r--cmd/sklad/main.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/sklad/main.go b/cmd/sklad/main.go
index 5b68e00..1baa66b 100644
--- a/cmd/sklad/main.go
+++ b/cmd/sklad/main.go
@@ -11,6 +11,7 @@ import (
"os"
"path"
"path/filepath"
+ "strings"
"time"
"janouch.name/sklad/imgutil"
@@ -73,9 +74,9 @@ func handleLogout(w http.ResponseWriter, r *http.Request) {
func handleContainerPost(r *http.Request) error {
id := ContainerId(r.FormValue("id"))
- description := r.FormValue("description")
+ description := strings.TrimSpace(r.FormValue("description"))
series := r.FormValue("series")
- parent := ContainerId(r.FormValue("parent"))
+ parent := ContainerId(strings.TrimSpace(r.FormValue("parent")))
_, remove := r.Form["remove"]
if container, ok := indexContainer[id]; ok {
@@ -150,8 +151,8 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
}
func handleSeriesPost(r *http.Request) error {
- prefix := r.FormValue("prefix")
- description := r.FormValue("description")
+ prefix := strings.TrimSpace(r.FormValue("prefix"))
+ description := strings.TrimSpace(r.FormValue("description"))
_, remove := r.Form["remove"]
if series, ok := indexSeries[prefix]; ok {