Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #103 from artygus/master
Browse files Browse the repository at this point in the history
Fix key generation
  • Loading branch information
grosser committed Oct 24, 2015
2 parents 129dc7a + 4f96d89 commit ba510b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/cache/key.rb
Expand Up @@ -43,7 +43,7 @@ def query_string
return nil if @request.query_string.nil?

@request.query_string.split(/[&;] */n).
map { |p| unescape(p).split('=', 2) }.
map { |p| p.split('=', 2).map{ |s| unescape(s) } }.
sort.
map { |k,v| "#{escape(k)}=#{escape(v)}" }.
join('&')
Expand Down
10 changes: 10 additions & 0 deletions test/key_test.rb
Expand Up @@ -19,6 +19,16 @@ def new_key(request)
new_key(request).must_include('a=first&z=last')
end

it "handles badly encoded params" do
request = mock_request('/test?%D0%BA=%D1')
new_key(request).must_include('%D0%BA=%D1')
end

it "doesn't confuse encoded equals sign with query string separator" do
request = mock_request('/test?weird%3Dkey=whatever')
new_key(request).must_include('weird%3Dkey=whatever')
end

it "includes the scheme" do
request = mock_request(
'/test',
Expand Down

0 comments on commit ba510b3

Please sign in to comment.