diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2023-03-23 18:21:59 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2023-03-23 18:21:59 +0300 |
commit | e1e1498c97c929821c3b84ff7dd1753fe3180ce4 (patch) | |
tree | 2c4544b623cfec4474c5d1e4f0388b3f6b99d017 /main.go | |
parent | d978dcc025da82176a6824fd596a545f431aa999 (diff) | |
download | static-wm-e1e1498c97c929821c3b84ff7dd1753fe3180ce4.tar.gz static-wm-e1e1498c97c929821c3b84ff7dd1753fe3180ce4.zip |
fix: add check for empty source host
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -21,11 +21,12 @@ type endpoint struct { // ServeHTTP is http.Handler implementation. func (ep endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) { source, err := url.Parse(r.PostFormValue("source")) - if err != nil { + if err != nil || source.Host == "" { w.WriteHeader(http.StatusBadRequest) w.Write([]byte(errSrcInvalid)) return } + if source.Scheme != "http" && source.Scheme != "https" { w.WriteHeader(http.StatusBadRequest) w.Write([]byte(errInvalidScheme)) |