diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-04-22 21:19:41 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-04-22 21:19:41 -0700 |
commit | f25a7c6661a31e69042ca1a51c6141c7e397c361 (patch) | |
tree | cb9edf92a2f60a49dba1f76104da9cf7787d8657 /src | |
parent | 36fed4cb7c6bd164f42b41d3bbfa909e9ded183f (diff) | |
parent | 1b36f68216087927646c2f79338a48afae08f8da (diff) | |
download | DotNetOpenAuth-f25a7c6661a31e69042ca1a51c6141c7e397c361.zip DotNetOpenAuth-f25a7c6661a31e69042ca1a51c6141c7e397c361.tar.gz DotNetOpenAuth-f25a7c6661a31e69042ca1a51c6141c7e397c361.tar.bz2 |
Merge branch 'v4.2' into v4.3
Diffstat (limited to 'src')
3 files changed, 9 insertions, 6 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs index eff035a..ab4aadf 100644 --- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs @@ -696,11 +696,14 @@ namespace DotNetOpenAuth.Messaging { /// Gets a NON-cryptographically strong random string of base64 characters. /// </summary> /// <param name="binaryLength">The length of the byte sequence to generate.</param> - /// <returns>A base64 encoding of the generated random data, - /// whose length in characters will likely be greater than <paramref name="binaryLength"/>.</returns> - internal static string GetNonCryptoRandomDataAsBase64(int binaryLength) { + /// <param name="useWeb64">A value indicating whether web64 encoding is used to avoid the need to escape characters.</param> + /// <returns> + /// A base64 encoding of the generated random data, + /// whose length in characters will likely be greater than <paramref name="binaryLength" />. + /// </returns> + internal static string GetNonCryptoRandomDataAsBase64(int binaryLength, bool useWeb64 = false) { byte[] uniq_bytes = GetNonCryptoRandomData(binaryLength); - string uniq = Convert.ToBase64String(uniq_bytes); + string uniq = useWeb64 ? ConvertToBase64WebSafeString(uniq_bytes) : Convert.ToBase64String(uniq_bytes); return uniq; } diff --git a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs index 879e4e3..277bed4 100644 --- a/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs +++ b/src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs @@ -113,7 +113,7 @@ namespace DotNetOpenAuth.OAuth2 { if (this.AuthorizationTracker == null) { var context = this.Channel.GetHttpContext(); - string xsrfKey = MessagingUtilities.GetNonCryptoRandomDataAsBase64(16); + string xsrfKey = MessagingUtilities.GetNonCryptoRandomDataAsBase64(16, useWeb64: true); cookie = new HttpCookie(XsrfCookieName, xsrfKey) { HttpOnly = true, Secure = FormsAuthentication.RequireSSL, diff --git a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs index d121e62..a313519 100644 --- a/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs +++ b/src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs @@ -209,7 +209,7 @@ namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration { // of language and country based on user settings. try { this.culture = CultureInfo.GetCultureInfo(cultureString); - } catch (CultureNotFoundException) { + } catch (ArgumentException) { // CultureNotFoundException derives from this, and .NET 3.5 throws the base type // Fallback to just reporting a culture based on language. this.culture = CultureInfo.GetCultureInfo(this.Language); } |