diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-18 22:08:07 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-18 22:08:07 -0800 |
commit | 32270c7413e7a2c37a02341a0894e2447f6d74f7 (patch) | |
tree | 05f6cf8566c7b4a2661a01d08967e91f05778837 /src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs | |
parent | 549017cdf590ea4ce4d8ad55c013c33a506133a3 (diff) | |
download | DotNetOpenAuth-32270c7413e7a2c37a02341a0894e2447f6d74f7.zip DotNetOpenAuth-32270c7413e7a2c37a02341a0894e2447f6d74f7.tar.gz DotNetOpenAuth-32270c7413e7a2c37a02341a0894e2447f6d74f7.tar.bz2 |
Matured the OAuth 1 consumer signing handler a bit.
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs')
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs index a4aff73..619f252 100644 --- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs @@ -1611,6 +1611,19 @@ namespace DotNetOpenAuth.Messaging { } /// <summary> + /// Enumerates all members of the collection as key=value pairs. + /// </summary> + internal static IEnumerable<KeyValuePair<string, string>> AsKeyValuePairs(this NameValueCollection nvc) { + Requires.NotNull(nvc, "nvc"); + + foreach (string key in nvc) { + foreach (string value in nvc.GetValues(key)) { + yield return new KeyValuePair<string, string>(key, value); + } + } + } + + /// <summary> /// Converts a <see cref="NameValueCollection"/> to an IDictionary<string, string>. /// </summary> /// <param name="nvc">The NameValueCollection to convert. May be null.</param> @@ -1881,6 +1894,11 @@ namespace DotNetOpenAuth.Messaging { internal static string EscapeUriDataStringRfc3986(string value) { Requires.NotNull(value, "value"); + // fast path for empty values. + if (value.Length == 0) { + return value; + } + // Start with RFC 2396 escaping by calling the .NET method to do the work. // This MAY sometimes exhibit RFC 3986 behavior (according to the documentation). // If it does, the escaping we do that follows it will be a no-op since the |