Skip to content

Commit

Permalink
Merge pull request #1493 from nesc58/fix-culture
Browse files Browse the repository at this point in the history
Ensure the correct culture is used
  • Loading branch information
alexeyzimarev authored Sep 5, 2020
2 parents 25debfa + 67907ea commit 2ebdbc2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static class OAuthExtensions
{
public static string ToRequestValue(this OAuthSignatureMethod signatureMethod)
{
var value = signatureMethod.ToString().ToUpper();
var value = signatureMethod.ToString().ToUpperInvariant();
var shaIndex = value.IndexOf("SHA", StringComparison.Ordinal);

return shaIndex > -1 ? value.Insert(shaIndex, "-") : value;
Expand Down
2 changes: 1 addition & 1 deletion src/RestSharp/Authenticators/OAuth/OAuthTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static string ConstructRequestUrl(Uri url)
public static string ConcatenateRequestElements(string method, string url, WebPairCollection parameters)
{
// Separating &'s are not URL encoded
var requestMethod = method.ToUpper().Then("&");
var requestMethod = method.ToUpperInvariant().Then("&");
var requestUrl = UrlEncodeRelaxed(ConstructRequestUrl(url.AsUri())).Then("&");
var requestParameters = UrlEncodeRelaxed(NormalizeRequestParameters(parameters));

Expand Down
4 changes: 2 additions & 2 deletions src/RestSharp/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public partial class Http : IHttp
{
const string LineBreak = "\r\n";

public string FormBoundary { get; } = "---------" + Guid.NewGuid().ToString().ToUpper();
public string FormBoundary { get; } = "---------" + Guid.NewGuid().ToString().ToUpperInvariant();

// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
static readonly Regex AddRangeRegex = new Regex("(\\w+)=(\\d+)-(\\d+)$");
Expand All @@ -53,7 +53,7 @@ public Http()

void AddSyncHeaderActions()
{
_restrictedHeaderActions.Add("Connection", (r, v) => { r.KeepAlive = v.ToLower().Contains("keep-alive"); });
_restrictedHeaderActions.Add("Connection", (r, v) => { r.KeepAlive = v.ToLowerInvariant().Contains("keep-alive"); });
_restrictedHeaderActions.Add("Content-Length", (r, v) => r.ContentLength = Convert.ToInt64(v));
_restrictedHeaderActions.Add("Expect", (r, v) => r.Expect = v);

Expand Down
6 changes: 3 additions & 3 deletions src/RestSharp/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void AddHandler(Func<IDeserializer> deserializerFactory, params string[] content

void DoBuildUriValidations(IRestRequest request)
{
if (BaseUrl == null && !request.Resource.ToLower().StartsWith("http"))
if (BaseUrl == null && !request.Resource.ToLowerInvariant().StartsWith("http"))
throw new ArgumentOutOfRangeException(
nameof(request),
"Request resource doesn't contain a valid scheme for an empty client base URL"
Expand Down Expand Up @@ -547,8 +547,8 @@ IRestResponse<T> Deserialize<T>(IRestRequest request, IRestResponse raw)
response = raw.ToAsyncResponse<T>();

// Only attempt to deserialize if the request has not errored due
// to a transport or framework exception. HTTP errors should attempt to
// be deserialized
// to a transport or framework exception. HTTP errors should attempt to
// be deserialized
if (response.ErrorException == null)
{
var func = GetHandler(raw.ContentType);
Expand Down
2 changes: 1 addition & 1 deletion src/RestSharp/Serializers/SerializeAsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public string TransformName(string input)
{
NameStyle.CamelCase => name.ToCamelCase(Culture),
NameStyle.PascalCase => name.ToPascalCase(Culture),
NameStyle.LowerCase => name.ToLower(),
NameStyle.LowerCase => name.ToLower(Culture),
_ => input
};
}
Expand Down
10 changes: 5 additions & 5 deletions src/RestSharp/Serializers/Xml/XmlDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected virtual object Map(object x, XElement root)
if (asType == typeof(bool))
{
var toConvert = value.ToString()
.ToLower();
.ToLower(Culture);

prop.SetValue(x, XmlConvert.ToBoolean(toConvert), null);
}
Expand Down Expand Up @@ -366,7 +366,7 @@ object HandleListDerivative(XElement root, string propName, Type type)

if (!elements.Any())
{
var lowerName = name.ToLower().AsNamespaced(Namespace);
var lowerName = name.ToLower(Culture).AsNamespaced(Namespace);

elements = root.Descendants(lowerName).ToList();
}
Expand All @@ -385,7 +385,7 @@ object HandleListDerivative(XElement root, string propName, Type type)

if (!elements.Any())
{
var lowerName = name.ToLower().AsNamespaced(Namespace);
var lowerName = name.ToLower(Culture).AsNamespaced(Namespace);

elements = root.Descendants()
.Where(e => e.Name.LocalName.RemoveUnderscoresAndDashes() == lowerName)
Expand Down Expand Up @@ -448,7 +448,7 @@ protected virtual object GetValueFromXml(XElement root, XName name, PropertyInfo

protected virtual XElement GetElementByName(XElement root, XName name)
{
var lowerName = name.LocalName.ToLower().AsNamespaced(name.NamespaceName);
var lowerName = name.LocalName.ToLower(Culture).AsNamespaced(name.NamespaceName);
var camelName = name.LocalName.ToCamelCase(Culture).AsNamespaced(name.NamespaceName);

if (root.Element(name) != null)
Expand Down Expand Up @@ -487,7 +487,7 @@ protected virtual XAttribute GetAttributeByName(XElement root, XName name, bool
: new List<XName>
{
name.LocalName,
name.LocalName.ToLower()
name.LocalName.ToLower(Culture)
.AsNamespaced(name.NamespaceName),
name.LocalName.ToCamelCase(Culture)
.AsNamespaced(name.NamespaceName)
Expand Down

0 comments on commit 2ebdbc2

Please sign in to comment.