Skip to content

Commit

Permalink
rename trimMultipleSlashes to sanitizeURI
Browse files Browse the repository at this point in the history
  • Loading branch information
aldas committed Feb 11, 2021
1 parent 5c4cb06 commit e3ef5ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions middleware/slash.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func AddTrailingSlashWithConfig(config TrailingSlashConfig) echo.MiddlewareFunc

// Redirect
if config.RedirectCode != 0 {
return c.Redirect(config.RedirectCode, sanitizeUri(uri))
return c.Redirect(config.RedirectCode, sanitizeURI(uri))
}

// Forward
Expand Down Expand Up @@ -108,7 +108,7 @@ func RemoveTrailingSlashWithConfig(config TrailingSlashConfig) echo.MiddlewareFu

// Redirect
if config.RedirectCode != 0 {
return c.Redirect(config.RedirectCode, sanitizeUri(uri))
return c.Redirect(config.RedirectCode, sanitizeURI(uri))
}

// Forward
Expand All @@ -120,7 +120,7 @@ func RemoveTrailingSlashWithConfig(config TrailingSlashConfig) echo.MiddlewareFu
}
}

func sanitizeUri(uri string) string {
func sanitizeURI(uri string) string {
// double slash `\\`, `//` or even `\/` is absolute uri for browsers and by redirecting request to that uri
// we are vulnerable to open redirect attack. so replace all slashes from the beginning with single slash
if len(uri) > 1 && (uri[0] == '\\' || uri[0] == '/') && (uri[1] == '\\' || uri[1] == '/') {
Expand Down

0 comments on commit e3ef5ac

Please sign in to comment.