Strip quotes for cookie values for .get() #140
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to RFC 2965, cookie value can be "quoted-string" and in practice, some web framework (e.g. Java Spring) sometimes uses quoted value.
In such cases, web browser will send HTTP headers like
Cookie: my_value_a=x; my_value_b="abc:def:xyz";
to the server and it will be more developer friendly to automatically strip quotes so thatcookie.get('my_value_b')
returnsabc:def:xyz
rather than"abc:def:xyz"
.Is this this library's responsibility?
I guess so. I checked the behavior of Django and Express and both of them strip quotes under the hood.
Django
_unquote
functionExpress
What's the impact of this change?
koa is relying on this library. After this fix, koa can get the same behavior as Django and Express, which seems to be more reasonable and common behavior. I created an issue for koa for the discussion in koa side.
Note that this change will be breaking change so we need to bump up the major version of the library.