]> Sergey Matveev's repositories - godlighty.git/commitdiff
Do not print raw URL path
authorSergey Matveev <stargrave@stargrave.org>
Fri, 8 Oct 2021 17:26:21 +0000 (20:26 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 8 Oct 2021 17:26:51 +0000 (20:26 +0300)
handler.go
rc/cgi.go
rc/example.cfg/proxied-host.go
rc/redirect.go

index df16c38d5e11bf05092f7c6b1bcaf606be8a87c7..4593a2f119262608082414f00e9da6713dd75260 100644 (file)
@@ -69,7 +69,7 @@ func (h Handler) Handle(
        host string, cfg *HostCfg,
 ) {
        notFound := func() {
-               fmt.Printf("%s %s \"%s %s %s\" %d \"%s\"\n",
+               fmt.Printf("%s %s \"%s %+q %s\" %d \"%s\"\n",
                        r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                        http.StatusNotFound,
                        r.Header.Get("User-Agent"),
@@ -90,7 +90,7 @@ func (h Handler) Handle(
                username = "user:" + username + " "
        }
        printErr := func(code int, err error) {
-               fmt.Printf("%s %s \"%s %s %s\" %d \"%s\" %s\"%s\"\n",
+               fmt.Printf("%s %s \"%s %+q %s\" %d \"%s\" %s\"%s\"\n",
                        r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                        code, err.Error(),
                        username, r.Header.Get("User-Agent"),
@@ -139,7 +139,7 @@ func (h Handler) Handle(
                }
                wc := &CountResponseWriter{ResponseWriter: w}
                dav.ServeHTTP(wc, r)
-               fmt.Printf("%s %s \"WebDAV %s\" %d %d %s\"%s\"\n",
+               fmt.Printf("%s %s \"WebDAV %+q\" %d %d %s\"%s\"\n",
                        r.RemoteAddr, host, r.URL.Path,
                        wc.Status, wc.Size,
                        username, r.Header.Get("User-Agent"),
@@ -148,7 +148,7 @@ func (h Handler) Handle(
        }
 
        if !(r.Method == "" || r.Method == http.MethodGet) {
-               fmt.Printf("%s %s \"%s %s %s\" %d %s\"%s\"\n",
+               fmt.Printf("%s %s \"%s %+q %s\" %d %s\"%s\"\n",
                        r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                        http.StatusMethodNotAllowed,
                        username, r.Header.Get("User-Agent"),
@@ -285,7 +285,7 @@ IndexLookup:
                wr := wc.(*gzipResponseWriter)
                w.WriteHeader(wr.status)
                w.Write(bufCompressed.Bytes())
-               fmt.Printf("%s %s \"%s %s %s\" %d %d %s\"%s\"\n",
+               fmt.Printf("%s %s \"%s %+q %s\" %d %d %s\"%s\"\n",
                        r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                        wr.status, size,
                        username, r.Header.Get("User-Agent"),
@@ -293,7 +293,7 @@ IndexLookup:
                return
        }
        wr := wc.(*CountResponseWriter)
-       fmt.Printf("%s %s \"%s %s %s\" %d %d %s\"%s\"\n",
+       fmt.Printf("%s %s \"%s %+q %s\" %d %d %s\"%s\"\n",
                r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                wr.Status, wr.Size,
                username, r.Header.Get("User-Agent"),
index 8dab80f9eb900a290b494c8d117d97ae162d7e4e..e17935a795af8491957492564b24fc0bf48ea2db 100644 (file)
--- a/rc/cgi.go
+++ b/rc/cgi.go
@@ -31,7 +31,7 @@ func RunCGIAndLog(host string, w http.ResponseWriter, r *http.Request, h *cgi.Ha
                h.Env = append(h.Env, "TLSREMOTEDN="+r.TLS.PeerCertificates[0].Subject.String())
        }
        h.ServeHTTP(wc, r)
-       fmt.Printf("%s %s \"%s %s %s\" %d %d \"%s\"\n",
+       fmt.Printf("%s %s \"%s %+q %s\" %d %d \"%s\"\n",
                r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                wc.Status, wc.Size,
                r.Header.Get("User-Agent"),
index 1ad0db6a0bda6bf39f1e8c539ae167e9c7a7af6e..5b61c4ddda343fae06699eee4d20a4ee380ca14e 100644 (file)
@@ -19,7 +19,7 @@ func init() {
                                r.Host = host
                                resp, err := http.DefaultClient.Do(r)
                                if err != nil {
-                                       fmt.Printf("%s %s \"%s %s %s\" %d \"%s\" \"%s\"\n",
+                                       fmt.Printf("%s %s \"%s %+q %s\" %d \"%s\" \"%s\"\n",
                                                r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                                                http.StatusBadGateway, err.Error(),
                                                r.Header.Get("User-Agent"),
@@ -35,7 +35,7 @@ func init() {
                                w.WriteHeader(resp.StatusCode)
                                size, _ := io.Copy(w, resp.Body)
                                resp.Body.Close()
-                               fmt.Printf("%s %s \"%s %s %s\" %d %d \"%s\"\n",
+                               fmt.Printf("%s %s \"%s %+q %s\" %d %d \"%s\"\n",
                                        r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                                        resp.StatusCode, size,
                                        r.Header.Get("User-Agent"),
index ecbdbfb98c048b9daecb27d579aa2dca50b98eb5..2039a076cd0e5f394d1e68f86ef97cebdcc2accd 100644 (file)
@@ -28,7 +28,7 @@ func Redirect(
        to string, status int,
 ) {
        http.Redirect(w, r, to, status)
-       fmt.Printf("%s %s \"%s %s %s\" %d \"%s\"\n",
+       fmt.Printf("%s %s \"%s %+q %s\" %d \"%s\"\n",
                r.RemoteAddr, host, r.Method, r.URL.Path, r.Proto,
                status, r.Header.Get("User-Agent"),
        )