Skip to content

Instantly share code, notes, and snippets.

@PanosJee
Created June 29, 2010 17:01
Show Gist options
  • Save PanosJee/457487 to your computer and use it in GitHub Desktop.
Save PanosJee/457487 to your computer and use it in GitHub Desktop.
From 1ca98a37b38a07387fc4344ce9df8db0a2885057 Mon Sep 17 00:00:00 2001
From: Panagiotis Papadopoulos <[email protected]>
Date: Tue, 29 Jun 2010 19:50:20 +0300
Subject: [PATCH] Added support for multiple query parameters with the same name
---
oauth/oauth.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/oauth/oauth.py b/oauth/oauth.py
index 286de18..386636e 100644
--- a/oauth/oauth.py
+++ b/oauth/oauth.py
@@ -227,8 +227,16 @@ class OAuthRequest(object):
except:
pass
# Escape key values before sorting.
- key_values = [(escape(_utf8_str(k)), escape(_utf8_str(v))) \
- for k,v in params.items()]
+ # Support multiple values for a query parameter as defined in OAuth spec
+ # at http://tools.ietf.org/html/rfc5849#section-3.4.1.3.2
+ key_values = []
+ for key, value in params.iteritems():
+ # 1.0a/9.1.1 states that kvp must be sorted by key, then by value,
+ # so we unpack sequence values into multiple items for sorting.
+ if hasattr(value, '__iter__'):
+ key_values.extend((key, item) for item in value)
+ else:
+ key_values.append((key, value))
# Sort lexicographically, first after key, then after value.
key_values.sort()
# Combine key value pairs into a string.
--
1.6.4.2+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment