-
-
Notifications
You must be signed in to change notification settings - Fork 119
Cookies with quotes #72
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
Conversation
Any chance to get this merged? |
Thanks @acordiner, that's really interesting! I was checking the complete cookies specs and looks like we are missing a bunch of stuff: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Directives |
There is actually a built-in Python library for handling cookies: https://docs.python.org/2/library/cookie.html |
Looks like for some reason that the This code: from http.cookies import Cookie
cookie = "_cookie_session=1266bb13c139cfba3ed1c9c68110bae9;" \
"expires=Thu, 29 Jan 2015 13:51:41 -0000; httponly;" \
"secure;Path=/gitlab"
dict(Cookie(cookie).values()[0]) Outputs:
While using from revproxy.utils import cookie_from_string
cookie_from_string(cookie) Outputs: {'expires': 'Thu, 29 Jan 2015 13:51:41 -0000',
'httponly': True,
'key': '_cookie_session',
'path': '/gitlab',
'secure': True,
'value': '1266bb13c139cfba3ed1c9c68110bae9'} |
735cb46
to
ea97417
Compare
I believe that the "expires" attribute must always end with "GMT" to comply with the RFC. If you change |
@acordiner the cookie in the test came from a real life example. Unfortunately even if the RFC says it needs to end with GMT if the browsers accept the I understand that your PR is quite important and useful but we need to take care of backward compatibility as well. |
How about if there is a setting for "strict" mode: if enabled it uses my code, if disabled it uses the previous code? The problem with the current code is that it is rejecting valid cookies. Specifically I am trying to use it with JupyterHub, but it doesn't work because JupyterHub uses cookies containing quotes. |
The strict mode seems a viable alternative but I would prefer to try to have the code working for both cases. If that helps you we can release a version with the strict arg (maybe a private property?) and then we revisit the implementation after. |
5d8f45c
to
1ba9b3b
Compare
1ba9b3b
to
2e3ffb3
Compare
1 similar comment
2e3ffb3
to
62fef6c
Compare
62fef6c
to
612e8c7
Compare
612e8c7
to
39bc69a
Compare
39bc69a
to
b214847
Compare
@seocam - For now I've added the strict mode as discussed. |
Any chance to get this merged? |
I'm gonna merge it but not release a version yet because it's missing docs. Could you please work on that? Thanks for the contribution! |
@seocam - I've added some documentation to |
This change permits cookie values to be quoted and contain equal signs, e.g.:
_cookie_session="hello=world"