Skip to content

Commit

Permalink
Add escape logic for header
Browse files Browse the repository at this point in the history
  • Loading branch information
t0rchwo0d committed Feb 16, 2023
1 parent c1d06e3 commit ff49e55
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gin.go
Expand Up @@ -9,6 +9,7 @@ import (
"html/template"
"net"
"net/http"
"net/url"
"os"
"path"
"strings"
Expand Down Expand Up @@ -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 + "/"
Expand Down

0 comments on commit ff49e55

Please sign in to comment.