From bf6728e53b27934b1d7dbabb5f53c4078815a244 Mon Sep 17 00:00:00 2001 From: jimchen Date: Tue, 20 Aug 2024 18:12:40 +0800 Subject: [PATCH] fix: fix URL path value still unescaped when UnescapePathValues set false Closes #4033 --- gin.go | 2 +- logger.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gin.go b/gin.go index 48cc15c9..7275fecd 100644 --- a/gin.go +++ b/gin.go @@ -645,7 +645,7 @@ func (engine *Engine) HandleContext(c *Context) { func (engine *Engine) handleHTTPRequest(c *Context) { httpMethod := c.Request.Method - rPath := c.Request.URL.Path + rPath := c.Request.URL.EscapedPath() unescape := false if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 { rPath = c.Request.URL.RawPath diff --git a/logger.go b/logger.go index db2c6832..741cdf00 100644 --- a/logger.go +++ b/logger.go @@ -242,7 +242,7 @@ func LoggerWithConfig(conf LoggerConfig) HandlerFunc { return func(c *Context) { // Start timer start := time.Now() - path := c.Request.URL.Path + path := c.Request.URL.EscapedPath() raw := c.Request.URL.RawQuery // Process request