Skip to content

Commit

Permalink
Merge pull request #670 from bdriggs-axian/bugfix/FixUrlEncoding
Browse files Browse the repository at this point in the history
Update to properly encode query string parameters
  • Loading branch information
douglasmiller authored Nov 3, 2021
2 parents 79be20f + 0430ae5 commit 6be887a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Recurly.Tests/BaseClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public void WillAddQueryStringParameters()
{
var options = new RequestOptions();
options.AddHeader("Accept-Language", "en-US");
var date = new DateTime(2020, 01, 01);
var date = DateTime.Parse("2020-01-01T08:00:00Z");
var paramsMatcher = MockClient.QueryParameterMatcher(new Dictionary<string, object> {
{ "param_1", "param1" },
{ "param_2", Recurly.Utils.ISO8601(date) },
{ "param_2", "2020-01-01T08%3A00%3A00.000Z" },
});

var client = MockClient.Build(paramsMatcher, SuccessResponse(System.Net.HttpStatusCode.OK));
Expand Down
4 changes: 3 additions & 1 deletion Recurly.Tests/UtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public void QueryString()
d.Add("decimal", 123.456m);
d.Add("date", new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc));
d.Add("enum", Recurly.Tests.Constants.EnumValue.AllowedEnum);
d.Add("email", "[email protected]");

var result = Utils.QueryString(d);
Assert.Equal("?trueBool=true&falseBool=false&int=123&decimal=123.456&date=2020-01-01T00:00:00.000Z&enum=allowed_enum", result);
Assert.Equal("?trueBool=true&falseBool=false&int=123&decimal=123.456&date=2020-01-01T00%3A00%3A00.000Z&enum=allowed_enum&email=testEmail%40example.org", result);
}
}
}
3 changes: 2 additions & 1 deletion Recurly/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static string QueryString(Dictionary<string, object> queryParams)
{
stringRepr = param.Value.ToString();
}
qString.Add($"{param.Key}={Uri.EscapeUriString(stringRepr)}");

qString.Add($"{param.Key}={Uri.EscapeDataString(stringRepr)}");
}
}

Expand Down

0 comments on commit 6be887a

Please sign in to comment.