Skip to content

Commit

Permalink
Fix URL encoding of HttpUtility.ParseQueryString's ToString method (#…
Browse files Browse the repository at this point in the history
…98263)

* Fix URL encoding of `HttpUtility.ParseQueryString`'s `ToString` method

* Add test
  • Loading branch information
RenderMichael authored Feb 12, 2024
1 parent b2d27d8 commit f582c0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override string ToString()
{
if (!string.IsNullOrEmpty(key))
{
sb.Append(key).Append('=');
sb.Append(UrlEncode(key)).Append('=');
}
sb.Append(UrlEncode(value)).Append('&');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ public void UrlPathEncode(string decoded, string encoded)
[InlineData("foo&bar")]
[InlineData("foo&name=bar")]
[InlineData("name=bar&foo&foo")]
[InlineData("_return_fields%2b=extattrs&name%3a=somename.somedomain.local")]
public void ParseAndToStringMaintainAllKeyValuePairs(string input)
{
var values = HttpUtility.ParseQueryString(input);
Expand Down

0 comments on commit f582c0b

Please # to comment.