From 30a6ab501d2e76096b0aada6bc53ad3e9856d891 Mon Sep 17 00:00:00 2001 From: Kevin Pham Date: Sun, 12 Nov 2023 17:02:32 -0600 Subject: [PATCH] handle URL encoded URLs in proxy for other app integrations --- handlers/proxy.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/handlers/proxy.go b/handlers/proxy.go index d58a635..886431a 100644 --- a/handlers/proxy.go +++ b/handlers/proxy.go @@ -25,7 +25,12 @@ var ( // extracts a URL from the request ctx. If the URL in the request // is a relative path, it reconstructs the full URL using the referer header. func extractUrl(c *fiber.Ctx) (string, error) { - reqUrl := c.Params("*") + // try to extract url-encoded + reqUrl, err := url.QueryUnescape(c.Params("*")) + if err != nil { + // fallback + reqUrl = c.Params("*") + } // Extract the actual path from req ctx urlQuery, err := url.Parse(reqUrl) @@ -199,6 +204,7 @@ func fetchSite(urlpath string, queries map[string]string) (string, *http.Request } if rule.Headers.CSP != "" { + log.Println(rule.Headers.CSP) resp.Header.Set("Content-Security-Policy", rule.Headers.CSP) }