Skip to content

Commit

Permalink
fix removing semicolon while decoding params (#145)
Browse files Browse the repository at this point in the history
* fix removing semicolon while decoding params

* fix unit test

---------

Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
  • Loading branch information
RamanaReddy0M and tarunKoyalwar committed May 5, 2023
1 parent 89f87ca commit 1b154eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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())
}
}

0 comments on commit 1b154eb

Please sign in to comment.