You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Cookie class takes the required $name and $value` parameters. These parameters are accepted "blindly". The only validation being done is checking that a string has been passed.
This can lead to surprising - and possibly incorrect - results when those cookies are formatted.
For both an empty key as well as an empty value, I'd expect the return to be an empty string (or an Exception).
For key only, I think the behaviour is correct.
For value only, I suspect the return value should be value-only (without the =).
Alternatively, I can imagine that a non-empty value for the key should be regarded as invalid and rejected with an exception when the Cookie is being constructed.
Additional context
This may need some research into RFCs on how cookies should be formatted.
Tested against develop branch?
I have verified the issue still exists in the develop branch of Requests.
The text was updated successfully, but these errors were encountered:
jrfnl
changed the title
Cookie::format_for_[header|set_cookie](): unexpected behaviour for key/value is empty
Cookie::format_for_[header|set_cookie](): unexpected behaviour for key/value when empty
May 24, 2022
Summary
Discovered while writing tests, see #740
The
Cookie
class takes the required$name
and $value` parameters. These parameters are accepted "blindly". The only validation being done is checking that a string has been passed.This can lead to surprising - and possibly incorrect - results when those cookies are formatted.
Given the following code sample
I'd expect the following behaviour
value-only
(without the=
).Alternatively, I can imagine that a non-empty value for the
key
should be regarded as invalid and rejected with an exception when the Cookie is being constructed.Additional context
This may need some research into RFCs on how cookies should be formatted.
Tested against
develop
branch?develop
branch of Requests.The text was updated successfully, but these errors were encountered: