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 removing semicolon while decoding params #145

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions url/rawparam.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ func (p Params) Decode(raw string) {
if AllowLegacySeperator {
arr = append(arr, tbuff.String())
tbuff.Reset()
continue
}
tbuff.WriteRune(v)
default:
tbuff.WriteRune(v)
}
Expand Down
17 changes: 17 additions & 0 deletions url/rawparam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,20 @@ func TestURLEncode(t *testing.T) {
require.Equalf(t, expected, got, "url encoding mismatch for non-printable char with ascii val:%v", r)
}
}

func TestURLDecode(t *testing.T) {
testcases := []struct {
url string
Expected Params
}{
{
"/ctc/servlet/ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=tasklist",
Params{"param": []string{"com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=tasklist"}},
},
}
for _, v := range testcases {
parsed, err := Parse(v.url)
require.Nilf(t, err, "failed to parse url %v", v.url)
require.Equalf(t, v.Expected, parsed.Query(), "failed to decode params in url %v expected %v got %v", v.url, v.Expected, parsed.Query())
}
}