Skip to content

Commit 4b25828

Browse files
committed
fix(serverHandler/mutate): use raw RequestURI to assemble redirect URL
`http.Redirect` will not escape special chars like '\' properly.
1 parent c2a2838 commit 4b25828

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/serverHandler/mutate.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package serverHandler
22

3-
import "net/http"
3+
import (
4+
"net/http"
5+
"strings"
6+
)
47

58
func (h *handler) mutate(w http.ResponseWriter, r *http.Request, data *responseData) {
69
success := false
@@ -34,6 +37,11 @@ func (h *handler) mutate(w http.ResponseWriter, r *http.Request, data *responseD
3437
}
3538
w.Write([]byte{'}'})
3639
} else {
37-
http.Redirect(w, r, r.URL.Path, http.StatusFound)
40+
reqPath := r.RequestURI
41+
qsIndex := strings.IndexByte(reqPath, '?')
42+
if qsIndex >= 0 {
43+
reqPath = reqPath[:qsIndex]
44+
}
45+
http.Redirect(w, r, reqPath, http.StatusFound)
3846
}
3947
}

0 commit comments

Comments
 (0)