mojodna-oauth 0.3.1.4 → 0.3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/oauth/cli.rb
CHANGED
@@ -106,7 +106,7 @@ module OAuth
|
|
106
106
|
options[:oauth_signature_method] = "HMAC-SHA1"
|
107
107
|
options[:oauth_timestamp] = OAuth::Helper.generate_timestamp
|
108
108
|
options[:oauth_version] = "1.0"
|
109
|
-
options[:params] =
|
109
|
+
options[:params] = []
|
110
110
|
|
111
111
|
opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
|
112
112
|
options[:oauth_consumer_key] = v
|
@@ -125,7 +125,7 @@ module OAuth
|
|
125
125
|
end
|
126
126
|
|
127
127
|
opts.on("--parameters PARAMS", "Specifies the parameters to use when signing.") do |v|
|
128
|
-
options[:params]
|
128
|
+
options[:params] << v
|
129
129
|
end
|
130
130
|
|
131
131
|
opts.on("--signature-method METHOD", "Specifies the signature method to use; defaults to HMAC-SHA1.") do |v|
|
@@ -176,9 +176,13 @@ module OAuth
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def prepare_parameters
|
179
|
-
escaped_pairs = options[:params].
|
180
|
-
|
181
|
-
[
|
179
|
+
escaped_pairs = options[:params].collect do |pair|
|
180
|
+
if pair =~ /:/
|
181
|
+
Hash[*pair.split(":", 2)].collect do |k,v|
|
182
|
+
[CGI.escape(k.strip), CGI.escape(v.strip)] * "="
|
183
|
+
end
|
184
|
+
else
|
185
|
+
pair
|
182
186
|
end
|
183
187
|
end
|
184
188
|
|
@@ -37,7 +37,7 @@ module OAuth::RequestProxy
|
|
37
37
|
params << header_params.to_query
|
38
38
|
params << request.query_string unless request.query_string.blank?
|
39
39
|
if request.content_type == Mime::Type.lookup("application/x-www-form-urlencoded")
|
40
|
-
params <<
|
40
|
+
params << request.raw_post
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,7 +45,7 @@ module OAuth::RequestProxy
|
|
45
45
|
join('&').split('&').
|
46
46
|
reject { |kv| kv =~ /^oauth_signature=.*/}.
|
47
47
|
reject(&:blank?).
|
48
|
-
map { |p| p.split('=') }
|
48
|
+
map { |p| p.split('=').map{|esc| CGI.unescape(esc)} }
|
49
49
|
end
|
50
50
|
|
51
51
|
protected
|
data/lib/oauth/version.rb
CHANGED
data/oauth.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{oauth}
|
5
|
-
s.version = "0.3.1.
|
5
|
+
s.version = "0.3.1.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons"]
|
@@ -18,6 +18,13 @@ class ActionControllerRequestProxyTest < Test::Unit::TestCase
|
|
18
18
|
request_proxy({ :message => { :body => 'This is a test' }}).parameters_for_signature
|
19
19
|
)
|
20
20
|
end
|
21
|
+
|
22
|
+
def test_parameter_values_with_amps_should_not_break_parameter_parsing
|
23
|
+
assert_equal(
|
24
|
+
[['message[body]', 'http://foo.com/?a=b&c=d']],
|
25
|
+
request_proxy({ :message => { :body => 'http://foo.com/?a=b&c=d'}}).parameters_for_signature
|
26
|
+
)
|
27
|
+
end
|
21
28
|
|
22
29
|
def test_parameter_keys_should_preserve_brackets_from_array
|
23
30
|
assert_equal(
|
@@ -25,4 +32,14 @@ class ActionControllerRequestProxyTest < Test::Unit::TestCase
|
|
25
32
|
request_proxy({ :foo => [123, 456] }).parameters_for_signature.sort
|
26
33
|
)
|
27
34
|
end
|
35
|
+
|
36
|
+
def test_query_string_parameter_values_should_be_cgi_unescaped
|
37
|
+
request = request_proxy do |r|
|
38
|
+
r.env['QUERY_STRING'] = 'url=http%3A%2F%2Ffoo.com%2F%3Fa%3Db%26c%3Dd'
|
39
|
+
end
|
40
|
+
assert_equal(
|
41
|
+
[['url', 'http://foo.com/?a=b&c=d']],
|
42
|
+
request.parameters_for_signature.sort
|
43
|
+
)
|
44
|
+
end
|
28
45
|
end
|