From: Sergey Matveev Date: Fri, 17 Feb 2023 14:47:19 +0000 (+0300) Subject: Safer query passing X-Git-Url: http://www.git.stargrave.org/?p=godlighty.git;a=commitdiff_plain;h=8730f9415046a1cc1242870c9443b34491d81d9d Safer query passing --- diff --git a/rc/example.cfg/proxied-host.go b/rc/example.cfg/proxied-host.go index 0af56cc..610379d 100644 --- a/rc/example.cfg/proxied-host.go +++ b/rc/example.cfg/proxied-host.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "net/url" "go.stargrave.org/godlighty" ) @@ -15,10 +16,13 @@ func init() { godlighty.Hosts[host] = &godlighty.HostCfg{ Hooks: []godlighty.Hook{ func(w http.ResponseWriter, r *http.Request) bool { + var err error + if r.URL, err = url.ParseRequestURI(r.RequestURI); err != nil { + panic(err) + } r.URL.Scheme = "http" r.URL.Host = "[dead::beaf]" r.RequestURI = "" - r.Host = host resp, err := http.DefaultClient.Do(r) if err != nil { fmt.Printf("%s %s \"%s %+q %s\" %d \"%s\" \"%s\"\n",