mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 23:40:35 +01:00
Merge pull request #972 from wozz/patch-1
Fix open redirect Former-commit-id: c2f89d48d6fd1e0b96f057d32cff58147b83b5f0
This commit is contained in:
commit
4ccf31eb44
|
@ -152,13 +152,14 @@ func (h *routerHandler) HandleRequest(ctx context.Context) {
|
|||
path := ctx.Path()
|
||||
if !ctx.Application().ConfigurationReadOnly().GetDisablePathCorrection() {
|
||||
|
||||
if len(path) > 1 && path[len(path)-1] == '/' {
|
||||
// Remove trailing slash and client-permant rule for redirection,
|
||||
if len(path) > 1 && strings.HasSuffix(path, "/") {
|
||||
// Remove trailing slash and client-permanent rule for redirection,
|
||||
// if confgiuration allows that and path has an extra slash.
|
||||
|
||||
// update the new path and redirect.
|
||||
r := ctx.Request()
|
||||
path = path[:len(path)-1]
|
||||
// use Trim to ensure there is no open redirect due to two leading slashes
|
||||
path = "/" + strings.Trim(path, "/")
|
||||
r.URL.Path = path
|
||||
url := r.URL.String()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user