From 8730f9415046a1cc1242870c9443b34491d81d9d Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Fri, 17 Feb 2023 17:47:19 +0300 Subject: [PATCH] Safer query passing --- rc/example.cfg/proxied-host.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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", -- 2.44.0