Skip to content

Commit

Permalink
The syntax of cookies is described in http://www.ietf.org/rfc/rfc2109…
Browse files Browse the repository at this point in the history
….txt,

section 4.1. Cookies are attribute-value pairs, so split should only return 2
values. This will allow '=' within the value of a cookie.
  • Loading branch information
dwnichols committed Jun 11, 2013
1 parent 45fdfd8 commit bd32f52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/httparty/cookie_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def add_cookies(value)
merge!(value)
when String
value.split('; ').each do |cookie|
array = cookie.split('=')
array = cookie.split('=',2)
self[array[0].to_sym] = array[1]
end
else
Expand Down
7 changes: 7 additions & 0 deletions spec/httparty/cookie_hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
@cookie_hash.length.should eql(1)
@cookie_hash[:foo].should eql("tar")
end

it "should handle '=' within cookie value" do
@cookie_hash.add_cookies("first=one=1; second=two=2==")
@cookie_hash.keys.should include(:first, :second)
@cookie_hash[:first].should == 'one=1'
@cookie_hash[:second].should == 'two=2=='
end
end

describe 'with other class' do
Expand Down

0 comments on commit bd32f52

Please sign in to comment.