Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URL path value still unescaped when UnescapePathValues set false #4036

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JimChenWYU
Copy link

Closes #4033

@@ -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()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

using Path it seem something wrong in this case.

gin.go Outdated
@@ -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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be changed right?
Now we are always routing based on the EscapedPath which changes the default behaviour

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be changed right? Now we are always routing based on the EscapedPath which changes the default behaviour

You are right.

gin.go Outdated
Comment on lines 648 to 651
rPath := c.Request.URL.EscapedPath()
unescape := false
if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 {
rPath = c.Request.URL.RawPath
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rPath := c.Request.URL.EscapedPath()
unescape := false
if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 {
rPath = c.Request.URL.RawPath
rPath := c.Request.URL.Path
unescape := false
if engine.UseRawPath {
rPath = c.Request.URL.EscapedPath()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] UnescapePathValues = false still unescapes path values
2 participants