Skip to content

Commit cf1944e

Browse files
committed
use %20 instead of + as encoded space
1 parent 0fe3f6c commit cf1944e

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.10.1
1+
1.10.1

lib/rack/oauth2/util.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ def parse_uri(uri)
3535

3636
def redirect_uri(base_uri, location, params)
3737
redirect_uri = parse_uri base_uri
38+
encoded_response_params = Util.compact_hash(params).to_query.gsub('+', '%20')
3839
case location
3940
when :query
40-
redirect_uri.query = [redirect_uri.query, Util.compact_hash(params).to_query].compact.join('&')
41+
redirect_uri.query = [redirect_uri.query, encoded_response_params].compact.join('&')
4142
when :fragment
42-
redirect_uri.fragment = Util.compact_hash(params).to_query
43+
redirect_uri.fragment = encoded_response_params
4344
end
4445
redirect_uri.to_s
4546
end
@@ -59,4 +60,4 @@ def uri_match?(base, given)
5960
end
6061
end
6162
end
62-
end
63+
end

spec/rack/oauth2/client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949

5050
context 'when response_type is an Array' do
5151
subject { client.authorization_uri(response_type: [:token, :code]) }
52-
it { should include 'response_type=token+code' }
52+
it { should include 'response_type=token%20code' }
5353
end
5454

5555
context 'when scope is given' do
5656
subject { client.authorization_uri(scope: [:scope1, :scope2]) }
57-
it { should include 'scope=scope1+scope2' }
57+
it { should include 'scope=scope1%20scope2' }
5858
end
5959
end
6060

spec/rack/oauth2/server/authorize/code_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
error: :access_denied,
5252
error_description: Rack::OAuth2::Server::Authorize::ErrorMethods::DEFAULT_DESCRIPTION[:access_denied]
5353
}
54-
response.location.should == "#{redirect_uri}?#{error_message.to_query}&state=state"
54+
response.location.should == "#{redirect_uri}?#{error_message.to_query.gsub('+', '%20')}&state=state"
5555
end
5656
end
5757
end

spec/rack/oauth2/server/authorize/extensions/code_and_token_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
error: :access_denied,
5555
error_description: Rack::OAuth2::Server::Authorize::ErrorMethods::DEFAULT_DESCRIPTION[:access_denied]
5656
}
57-
response.location.should == "#{redirect_uri}##{error_message.to_query}"
57+
response.location.should == "#{redirect_uri}##{error_message.to_query.gsub('+', '%20')}"
5858
end
5959
end
6060
end

spec/rack/oauth2/server/authorize/token_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
error: :access_denied,
6868
error_description: Rack::OAuth2::Server::Authorize::ErrorMethods::DEFAULT_DESCRIPTION[:access_denied]
6969
}
70-
response.location.should == "#{redirect_uri}##{error_message.to_query}&state=state"
70+
response.location.should == "#{redirect_uri}##{error_message.to_query.gsub('+', '%20')}&state=state"
7171
end
7272
end
7373
end

0 commit comments

Comments
 (0)