Add escape logic for header (#3500)

This commit is contained in:
t0rchwo0d
2023-02-17 11:00:19 +09:00
committed by GitHub
parent d07db174ac
commit 81ac7d55a0
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -9,6 +9,7 @@ import (
"html/template"
"net"
"net/http"
"net/url"
"os"
"path"
"strings"
@@ -668,6 +669,9 @@ func redirectTrailingSlash(c *Context) {
req := c.Request
p := req.URL.Path
if prefix := path.Clean(c.Request.Header.Get("X-Forwarded-Prefix")); prefix != "." {
prefix = url.QueryEscape(prefix)
prefix = strings.ReplaceAll(prefix, "%2F", "/")
p = prefix + "/" + req.URL.Path
}
req.URL.Path = p + "/"