Skip to content

Commit f25a7c6

Browse files
committed
Merge branch 'v4.2' into v4.3
2 parents 36fed4c + 1b36f68 commit f25a7c6

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,14 @@ internal static string GetCryptoRandomDataAsBase64(int binaryLength) {
696696
/// Gets a NON-cryptographically strong random string of base64 characters.
697697
/// </summary>
698698
/// <param name="binaryLength">The length of the byte sequence to generate.</param>
699-
/// <returns>A base64 encoding of the generated random data,
700-
/// whose length in characters will likely be greater than <paramref name="binaryLength"/>.</returns>
701-
internal static string GetNonCryptoRandomDataAsBase64(int binaryLength) {
699+
/// <param name="useWeb64">A value indicating whether web64 encoding is used to avoid the need to escape characters.</param>
700+
/// <returns>
701+
/// A base64 encoding of the generated random data,
702+
/// whose length in characters will likely be greater than <paramref name="binaryLength" />.
703+
/// </returns>
704+
internal static string GetNonCryptoRandomDataAsBase64(int binaryLength, bool useWeb64 = false) {
702705
byte[] uniq_bytes = GetNonCryptoRandomData(binaryLength);
703-
string uniq = Convert.ToBase64String(uniq_bytes);
706+
string uniq = useWeb64 ? ConvertToBase64WebSafeString(uniq_bytes) : Convert.ToBase64String(uniq_bytes);
704707
return uniq;
705708
}
706709

src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public OutgoingWebResponse PrepareRequestUserAuthorization(IAuthorizationState a
113113
if (this.AuthorizationTracker == null) {
114114
var context = this.Channel.GetHttpContext();
115115

116-
string xsrfKey = MessagingUtilities.GetNonCryptoRandomDataAsBase64(16);
116+
string xsrfKey = MessagingUtilities.GetNonCryptoRandomDataAsBase64(16, useWeb64: true);
117117
cookie = new HttpCookie(XsrfCookieName, xsrfKey) {
118118
HttpOnly = true,
119119
Secure = FormsAuthentication.RequireSSL,

src/DotNetOpenAuth.OpenId/OpenId/Extensions/SimpleRegistration/ClaimsResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public CultureInfo Culture {
209209
// of language and country based on user settings.
210210
try {
211211
this.culture = CultureInfo.GetCultureInfo(cultureString);
212-
} catch (CultureNotFoundException) {
212+
} catch (ArgumentException) { // CultureNotFoundException derives from this, and .NET 3.5 throws the base type
213213
// Fallback to just reporting a culture based on language.
214214
this.culture = CultureInfo.GetCultureInfo(this.Language);
215215
}

0 commit comments

Comments
 (0)