gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
https://gin-gonic.com/
MIT License
78.84k stars 8.02k forks source link

code comment of Engine.UnescapePathValues #2285

Open xiaosongluffy opened 4 years ago

xiaosongluffy commented 4 years ago

Engine.UnescapePathValues comment make me confused.

// If true, the path value will be unescaped.
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
// as url.Path gonna be used, which is already unescaped.
UnescapePathValues bool

It should be:

// If true, the path value will be unescaped.
// If UseRawPath is false (by default), the UnescapePathValues effectively is  false,
// as url.Path gonna be used, which is already unescaped.
UnescapePathValues bool

refer to logic of code below:

func (engine *Engine) handleHTTPRequest(c *Context) {
    httpMethod := c.Request.Method
    rPath := c.Request.URL.Path
    unescape := false
    if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 {
        rPath = c.Request.URL.RawPath
        unescape = engine.UnescapePathValues
    }
       // .....
}
trainoasis commented 2 years ago

Seems nobody cares, but yeah, this needs to be changed. Perhaps make a PR?