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

Passing cookies via middleware, ensure cookies are escaped #70

Merged
merged 14 commits into from
Jun 30, 2020

Conversation

braindeaf
Copy link
Contributor

It appears I missed a vital part of passing cookies from middleware, Rack::Utils unescapes cookies and they need to be re-escaped.

cookies: [{ domain: 'www.example.org', name: 'key', value: 'value' }]
cookies: [
{ domain: 'www.example.org', name: 'key', value: 'value' },
{ domain: 'www.example.org', name: 'escaped', value: '%26%3D%3D'}
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like a reasonable test, however i'd suggest it would also be good to have a test that actually calls to Grover/Puppeteer with some encoded cookies, have the page render the contents then check the result contains the expected encoded values. Hopefully that way there will be less risk of future regressions. This would probably live in the processor_spec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I shall make it so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added that spec, but all it really does it prove that you can pass a cookies, escaped or not to Puppeteer, the real failure on this was not realising that the cookie parser had escaped it. My bad.

Copy link
Contributor

@abrom abrom left a comment

Choose a reason for hiding this comment

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

Change looks good @braindeaf 👍

Note per my comments I've fixed up the cookie renderer app to decode the cookie properly which now breaks your spec. Good news though is that the spec (once fixed) will make sense!

@@ -1,7 +1,6 @@
# Changelog

## Unreleased
- None
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add an entry here for your change. Likely

### Fixed
- [#70](https://github.com/Studiosity/grover/pull/70) Ensure cookies are escaped when passing cookies via middleware ([@braindeaf][])

spec/grover/processor_spec.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@abrom abrom left a comment

Choose a reason for hiding this comment

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

Change looks great, thanks @braindeaf 👍

@abrom abrom merged commit 19738ad into Studiosity:main Jun 30, 2020
@abrom
Copy link
Contributor

abrom commented Jul 1, 2020

FYI this has been released in v0.12.3

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.

2 participants