From 9858f4403d0735e57090f5b615f3adf4b9dd40b1 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 22 May 2017 19:04:18 +0100 Subject: [PATCH] Fix the client API proxy to handle '#' correctly --- .../matrix-org/dendrite/cmd/client-api-proxy/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go b/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go index 505026756..fb8751cad 100644 --- a/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go @@ -76,7 +76,11 @@ func makeProxy(targetURL string) (*httputil.ReverseProxy, error) { "url": targetURL, "method": req.Method, }).Print("proxying request") - newURL, err := url.Parse(targetURL + path) + newURL, err := url.Parse(targetURL) + // Set the path separately as we need to preserve '#' characters + // that would otherwise be interpreted as being the start of a URL + // fragment. + newURL.Path += path if err != nil { // We already checked that we can parse the URL // So this shouldn't ever get hit.