mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-06 12:08:20 +08:00
Merge a48b9f623a2050b58d4e2fca09ff1d842c7b863f into d75fcd4c9ab260e5225de590f1f0f8c0e0e12d11
This commit is contained in:
commit
7872a42cc5
4
tree.go
4
tree.go
@ -511,7 +511,7 @@ walk: // Outer loop for walking the tree
|
|||||||
*value.params = (*value.params)[:i+1]
|
*value.params = (*value.params)[:i+1]
|
||||||
val := path[:end]
|
val := path[:end]
|
||||||
if unescape {
|
if unescape {
|
||||||
if v, err := url.QueryUnescape(val); err == nil {
|
if v, err := url.PathUnescape(val); err == nil {
|
||||||
val = v
|
val = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ walk: // Outer loop for walking the tree
|
|||||||
*value.params = (*value.params)[:i+1]
|
*value.params = (*value.params)[:i+1]
|
||||||
val := path
|
val := path
|
||||||
if unescape {
|
if unescape {
|
||||||
if v, err := url.QueryUnescape(path); err == nil {
|
if v, err := url.PathUnescape(val); err == nil {
|
||||||
val = v
|
val = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -345,10 +345,11 @@ func TestUnescapeParameters(t *testing.T) {
|
|||||||
{"/cmd/test/", false, "/cmd/:tool/", Params{Param{Key: "tool", Value: "test"}}},
|
{"/cmd/test/", false, "/cmd/:tool/", Params{Param{Key: "tool", Value: "test"}}},
|
||||||
{"/cmd/test", true, "", Params{Param{Key: "tool", Value: "test"}}},
|
{"/cmd/test", true, "", Params{Param{Key: "tool", Value: "test"}}},
|
||||||
{"/src/some/file.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file.png"}}},
|
{"/src/some/file.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file.png"}}},
|
||||||
{"/src/some/file+test.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file test.png"}}},
|
{"/src/some/file+test.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file+test.png"}}},
|
||||||
{"/src/some/file++++%%%%test.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file++++%%%%test.png"}}},
|
{"/src/some/file++++%%%%test.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file++++%%%%test.png"}}},
|
||||||
{"/src/some/file%2Ftest.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file/test.png"}}},
|
{"/src/some/file%2Ftest.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file/test.png"}}},
|
||||||
{"/search/someth!ng+in+ünìcodé", false, "/search/:query", Params{Param{Key: "query", Value: "someth!ng in ünìcodé"}}},
|
{"/src/some/file%2Btest.png", false, "/src/*filepath", Params{Param{Key: "filepath", Value: "/some/file+test.png"}}},
|
||||||
|
{"/search/someth!ng+in+ünìcodé", false, "/search/:query", Params{Param{Key: "query", Value: "someth!ng+in+ünìcodé"}}},
|
||||||
{"/info/gordon/project/go", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "gordon"}, Param{Key: "project", Value: "go"}}},
|
{"/info/gordon/project/go", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "gordon"}, Param{Key: "project", Value: "go"}}},
|
||||||
{"/info/slash%2Fgordon", false, "/info/:user", Params{Param{Key: "user", Value: "slash/gordon"}}},
|
{"/info/slash%2Fgordon", false, "/info/:user", Params{Param{Key: "user", Value: "slash/gordon"}}},
|
||||||
{"/info/slash%2Fgordon/project/Project%20%231", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "slash/gordon"}, Param{Key: "project", Value: "Project #1"}}},
|
{"/info/slash%2Fgordon/project/Project%20%231", false, "/info/:user/project/:project", Params{Param{Key: "user", Value: "slash/gordon"}, Param{Key: "project", Value: "Project #1"}}},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user