Skip to content

Commit 6b1e216

Browse files
committed
Merge pull request #219 from Haacked/stringcomparisonfix
Changed string comparisons to use `OrdinalIgnoreCase`
2 parents db44f42 + b717259 commit 6b1e216

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

RestSharp/Authenticators/HttpBasicAuthenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void Authenticate(IRestClient client, IRestRequest request) {
3939
// request.Credentials = new NetworkCredential(_username, _password);
4040

4141
// only add the Authorization parameter if it hasn't been added by a previous Execute
42-
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.InvariantCultureIgnoreCase)))
42+
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
4343
{
4444
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", _username, _password)));
4545
var authHeader = string.Format("Basic {0}", token);

RestSharp/Authenticators/OAuth/Extensions/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static bool IsNullOrBlank(this string value)
2929

3030
public static bool EqualsIgnoreCase(this string left, string right)
3131
{
32-
return String.Compare(left, right, StringComparison.InvariantCultureIgnoreCase) == 0;
32+
return String.Compare(left, right, StringComparison.OrdinalIgnoreCase) == 0;
3333
}
3434

3535
public static bool EqualsAny(this string input, params string[] args)

RestSharp/Authenticators/OAuth2Authenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public OAuth2AuthorizationRequestHeaderAuthenticator(string accessToken)
9797
public override void Authenticate(IRestClient client, IRestRequest request)
9898
{
9999
// only add the Authorization parameter if it hasn't been added.
100-
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.InvariantCultureIgnoreCase)))
100+
if (!request.Parameters.Any(p => p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
101101
{
102102
request.AddParameter("Authorization", _authorizationValue, ParameterType.HttpHeader);
103103
}

RestSharp/Http.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private static void ExtractResponseData(HttpResponse response, HttpWebResponse w
320320
response.ContentType = webResponse.ContentType;
321321
response.ContentLength = webResponse.ContentLength;
322322
#if WINDOWS_PHONE
323-
if (string.Equals(webResponse.Headers[HttpRequestHeader.ContentEncoding], "gzip", StringComparison.InvariantCultureIgnoreCase))
323+
if (string.Equals(webResponse.Headers[HttpRequestHeader.ContentEncoding], "gzip", StringComparison.OrdinalIgnoreCase))
324324
response.RawBytes = new GZipStream(webResponse.GetResponseStream()).ReadAsBytes();
325325
else
326326
response.RawBytes = webResponse.GetResponseStream().ReadAsBytes();

0 commit comments

Comments
 (0)