-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Path Parameters don't consistently decode #2168
Comments
This seems to be more standard library problem as uppercase/lowercase hex escaping is done there. This is where Echo chooses path Lines 902 to 908 in ec92fed
so when you do request as you see path has already unescaped func TestURL_ParseEscapingHexValues(t *testing.T) {
var testCases = []struct {
name string
when string
expectPath string
expectRawPath string
}{
{
name: "uppercase F in %3f",
when: "/example/ab%3Fde",
expectPath: "/example/ab?de",
expectRawPath: `/example/ab%3Fde`, // actual RawPath is empty and test fails
},
{
name: "lowercase f in %3f",
when: "/example/ab%3fde",
expectPath: "/example/ab?de",
expectRawPath: `/example/ab%3fde`,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
u, _ := url.Parse(tc.when)
if u.Path != tc.expectPath {
t.Errorf("path `%s` is not `%s`", u.Path, tc.expectPath)
}
if u.RawPath != tc.expectRawPath {
t.Errorf("RawPath `%s` is not `%s`", u.RawPath, tc.expectRawPath)
}
})
}
} This is where https://github.com/golang/go/blob/fd6c556dc82253722a7f7b9f554a1892b0ede36e/src/net/url/url.go#L676 |
Somewhat related issues
Also |
golang/go#33596 looks to be exactly it. Somewhat concerning that it's been untouched for 3 years though, given the potential implications that it has :\ |
golang/go#53848 should fix this issue. |
Issue Description
This was noticed as part of #2165. When a handler has path parameters, any URL encoded hex pairs are correctly decoded if they are in uppercase but not in lowercase.
That is:
%3F
=>?
%3f
=>%3f
It is impossible to safely decode this in the handler if it might or might not have been decoded in the router - or worse, if some of it has been decoded and other bits haven't.
For example, if the handler sees
%3f
then it's impossible to know if this is:%3f
that wasn't decoded.%253f
that was decoded.Note that RFC-3986 states:
Checklist
Expected behaviour
Path parameters should be URL decoded regardless of the case of the hex pairs.
Actual behaviour
Lowercase hex pairs do not get decoded correctly.
Steps to reproduce
Working code to debug
If you call this as
/example/ab%3Fde
then the output isab?de
. If however you call it as/example/ab%3fde
then the output isab%3fde
.Version/commit
The text was updated successfully, but these errors were encountered: