Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for Cookies with multiple paths #197

Merged
merged 2 commits into from
Aug 3, 2017
Merged

Bugfix for Cookies with multiple paths #197

merged 2 commits into from
Aug 3, 2017

Conversation

kylewelsby
Copy link
Contributor

closes #16 "Rack::Test::CookieJar cannot handle multiple 'path' values in the Cookie."

However this is not a valid cookie string, I've found some web servers that ignore this and still deliver multiple keys.

http://www.w3.org/Protocols/rfc2109/rfc2109

4.2.2 Set-Cookie Syntax

... If an attribute appears more than once in a cookie, the behavior is undefined. ...

rebased after notification from #92

Copy link
Contributor

@perlun perlun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort @kylewelsby, much appreciated! 👍 A few things that I think should be addressed, but should be mergable afterwards.

@@ -45,7 +70,7 @@
it 'allow symbol access' do
jar = Rack::Test::CookieJar.new
jar['value'] = 'foo;abc'
jar[:value].should == 'foo;abc'
expect(jar[:value]).to eql('foo;abc')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer eq to eql, since that's what's being used elsewhere in the code. (unless it actually causes a different result, but I don't think it should in this case)

@@ -28,6 +28,31 @@
expect(last_request.cookies).to eq({})
end

it 'uses the first path when many paths are defiend' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: defiend vs defiend

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good spot. did write this a few years ago.

].join('; ')
cookie = Rack::Test::Cookie.new(cookie_string)
expect(cookie.path).to eql '/'
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in spec name, and also a misleading name (it only provides a single path 😄), so you probably intended to write something else?

Also, prefer eq to eql in the expect calls, in both new tests.

@kylewelsby
Copy link
Contributor Author

Hey @perlun I have pushed the requested changes. 😇

Copy link
Contributor

@perlun perlun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there now! 😉

].join('; ')
cookie = Rack::Test::Cookie.new(cookie_string)
expect(cookie.path).to eq('/')
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one still has the typo + misleading name. it 'properly uses a single path being defined' or something is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this. Thanks for pointing it out.

@perlun
Copy link
Contributor

perlun commented Aug 3, 2017

Thanks @kylewelsby, will merge this now.

@perlun perlun merged commit 0047c07 into rack:master Aug 3, 2017
alex-damian-negru pushed a commit to alex-damian-negru/rack-test that referenced this pull request Apr 5, 2021
* Bugfix for Cookies with multiple paths

closes rack#16

* Fixed spec names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rack::Test::CookieJar cannot handle multiple 'path' values in the Cookie.
2 participants