From e1e1498c97c929821c3b84ff7dd1753fe3180ce4 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Thu, 23 Mar 2023 18:21:59 +0300 Subject: fix: add check for empty source host --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'main.go') diff --git a/main.go b/main.go index 41f8334..366ebde 100644 --- a/main.go +++ b/main.go @@ -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)) -- cgit v1.2.3