From 29db90e1fc90a8a4fe88c5bb78bb07c8a27c3281 Mon Sep 17 00:00:00 2001 From: cyal1 <33282478+cyal1@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:50:18 +0800 Subject: [PATCH] fixed open redirect --- gin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gin.go b/gin.go index 69bf1673..bcfc37c0 100644 --- a/gin.go +++ b/gin.go @@ -699,7 +699,7 @@ func redirectTrailingSlash(c *Context) { p = prefix + "/" + req.URL.Path } req.URL.Path = p + "/" - p = regRemoveRepeatedChar.ReplaceAllString(p, "/") + p = regexp.MustCompile("^/{2,}").ReplaceAllString(p, "/") if length := len(p); length > 1 && p[length-1] == '/' { req.URL.Path = p[:length-1] }