From 809e86bbf8ed478e7aa7b9de8a3bfc3014289bd5 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 12 Nov 2015 22:57:06 +0700 Subject: Review of culture-independent String comparison methods --- crypto/src/asn1/x509/GeneralName.cs | 5 +++-- crypto/src/asn1/x509/X509Name.cs | 16 +++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'crypto/src/asn1/x509') diff --git a/crypto/src/asn1/x509/GeneralName.cs b/crypto/src/asn1/x509/GeneralName.cs index 710ddc922..16096623c 100644 --- a/crypto/src/asn1/x509/GeneralName.cs +++ b/crypto/src/asn1/x509/GeneralName.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Text; +using Org.BouncyCastle.Utilities; using NetUtils = Org.BouncyCastle.Utilities.Net; namespace Org.BouncyCastle.Asn1.X509 @@ -356,11 +357,11 @@ namespace Org.BouncyCastle.Asn1.X509 private int[] parseIPv6(string ip) { - if (ip.StartsWith("::")) + if (Platform.StartsWith(ip, "::")) { ip = ip.Substring(1); } - else if (ip.EndsWith("::")) + else if (Platform.EndsWith(ip, "::")) { ip = ip.Substring(0, ip.Length - 1); } diff --git a/crypto/src/asn1/x509/X509Name.cs b/crypto/src/asn1/x509/X509Name.cs index fb404a3ec..01a7ec04a 100644 --- a/crypto/src/asn1/x509/X509Name.cs +++ b/crypto/src/asn1/x509/X509Name.cs @@ -399,7 +399,7 @@ namespace Org.BouncyCastle.Asn1.X509 if (derValue is IAsn1String && !(derValue is DerUniversalString)) { string v = ((IAsn1String)derValue).GetString(); - if (v.StartsWith("#")) + if (Platform.StartsWith(v, "#")) { v = "\\" + v; } @@ -499,12 +499,6 @@ namespace Org.BouncyCastle.Asn1.X509 } } -// private static bool IsEncoded( -// string s) -// { -// return s.StartsWith("#"); -// } - /** * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or * some such, converting it into an ordered set of name attributes. @@ -581,7 +575,7 @@ namespace Org.BouncyCastle.Asn1.X509 string name, IDictionary lookUp) { - if (Platform.ToUpperInvariant(name).StartsWith("OID.")) + if (Platform.StartsWith(Platform.ToUpperInvariant(name), "OID.")) { return new DerObjectIdentifier(name.Substring(4)); } @@ -724,7 +718,7 @@ namespace Org.BouncyCastle.Asn1.X509 { string val = (string)values[i]; - if (val.StartsWith("\\#")) + if (Platform.StartsWith(val, "\\#")) { val = val.Substring(1); } @@ -911,7 +905,7 @@ namespace Org.BouncyCastle.Asn1.X509 { string v = Platform.ToLowerInvariant(s).Trim(); - if (v.StartsWith("#")) + if (Platform.StartsWith(v, "#")) { Asn1Object obj = decodeObject(v); @@ -987,7 +981,7 @@ namespace Org.BouncyCastle.Asn1.X509 int end = buf.Length; - if (val.StartsWith("\\#")) + if (Platform.StartsWith(val, "\\#")) { index += 2; } -- cgit 1.4.1