You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 23:57:34 UTC
[30/50] git commit: Use correct request parameter normalization
algorithm.
Use correct request parameter normalization algorithm.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/commit/b9dcd4f8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/tree/b9dcd4f8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-oauth/diff/b9dcd4f8
Branch: refs/heads/import
Commit: b9dcd4f8e31218e549aadfd870d1147bcee1159c
Parents: dcbf227
Author: Tim Fletcher <ma...@tfletcher.com>
Authored: Sat Jan 29 17:11:11 2011 +0000
Committer: Tim Fletcher <ma...@tfletcher.com>
Committed: Sat Jan 29 17:11:11 2011 +0000
----------------------------------------------------------------------
src/oauth.erl | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-oauth/blob/b9dcd4f8/src/oauth.erl
----------------------------------------------------------------------
diff --git a/src/oauth.erl b/src/oauth.erl
index c6467d9..f2fa946 100644
--- a/src/oauth.erl
+++ b/src/oauth.erl
@@ -61,9 +61,16 @@ signature(HttpMethod, URL, Params, Consumer, TokenSecret) ->
signature_base_string(HttpMethod, URL, Params) ->
NormalizedURL = oauth_uri:normalize(URL),
- NormalizedParams = oauth_uri:params_to_string(lists:sort(Params)),
+ NormalizedParams = normalized_params_string(Params),
oauth_uri:calate("&", [HttpMethod, NormalizedURL, NormalizedParams]).
+normalized_params_string(Params) ->
+ % cf. http://tools.ietf.org/html/rfc5849#section-3.4.1.3.2
+ Encoded = [{oauth_uri:encode(K), oauth_uri:encode(V)} || {K, V} <- Params],
+ Sorted = lists:sort(Encoded),
+ Concatenated = [lists:concat([K, "=", V]) || {K, V} <- Sorted],
+ string:join(Concatenated, "&").
+
token_param("", Params) ->
Params;
token_param(Token, Params) ->