diff options
author | AkosLukacs <AkosLukacs42@gmail.com> | 2013-03-15 17:25:58 +0100 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-17 16:33:13 -0700 |
commit | f103d48725ec6baf5e3717e441f559f6b0b2276b (patch) | |
tree | 14117b0f8b78d8b00cfc0adb92ed43dee87125bb /src | |
parent | 34f110c4981f2d8fab3aa36a7b1ff614e9d38189 (diff) | |
download | DotNetOpenAuth-f103d48725ec6baf5e3717e441f559f6b0b2276b.zip DotNetOpenAuth-f103d48725ec6baf5e3717e441f559f6b0b2276b.tar.gz DotNetOpenAuth-f103d48725ec6baf5e3717e441f559f6b0b2276b.tar.bz2 |
A possible fix for exception in ClaimsResponse.Culture, if Language + Country doesn't make a valid culture.
https://github.com/DotNetOpenAuth/DotNetOpenAuth/issues/260
Just a simple try-catch. According to this comment at SO http://stackoverflow.com/a/12375100 using try-catch is the fastest is you don't expect a continuous stream of illegal combinations.
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs index af60596..4cd32f2 100644 --- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs +++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs @@ -203,7 +203,13 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { if (!string.IsNullOrEmpty(this.Country)) { cultureString += "-" + this.Country; } - this.culture = CultureInfo.GetCultureInfo(cultureString); + //Language + Country not neccessarily make a valid culture identifier + try { + this.culture = CultureInfo.GetCultureInfo(cultureString); + } + catch(CultureNotFoundException) { + this.culture = CultureInfo.GetCultureInfo(this.Language); + } } return this.culture; |