Open
Description
Description
'+' plus signs in path parameters are unescaped to ' ' (the space character) when UnescapePathValues and UseRawPath are set to true.
However this problem does not appear if the URL path segment does not contain %2F (URLencoded '/').
Changing
Line 446 in a573ec6
url.PathUnescape
might fix the problem.
How to reproduce
package main
import (
"github.com/gin-gonic/gin"
)
func main() {
r := gin.New()
r.UseRawPath = true
r.GET("/:name/hi", func(c *gin.Context) {
c.String(200, "Hello %s", c.Param("name"))
})
r.Run(":9000")
}
Expectations
$ curl 'http://localhost:9000/a+file.txt/hi'
Hello a+file.txt
$ curl 'http://localhost:9000/a+%2Ffile.txt/hi'
Hello a+/file.txt
Actual result
$ curl 'http://localhost:9000/a+file.txt/hi'
Hello a+file.txt
$ curl 'http://localhost:9000/a+%2Ffile.txt/hi'
Hello a /file.txt
Environment
- go version: go1.15.2
- gin version (or commit ref): gin v1.6.3
- operating system: linux/amd64
Metadata
Assignees
Labels
No labels
Activity