-
-
Notifications
You must be signed in to change notification settings - Fork 500
Open
Labels
Bug 🐛This is something that is not working as expectedThis is something that is not working as expected
Description
Description
The parse_cookie_string() function incorrectly handles attributes without values and will keep only one due to the dictionary conversion.
For example if the cookie contains the HttpOnly and the Secure attributes these will both have an empty string as key and eventually only one of these will be returned.

URL to code causing the issue
Lines 50 to 67 in 3dfd6fe
| def parse_cookie_string(cookie_string: str) -> dict[str, str]: | |
| """Parse a cookie string into a dictionary of values. | |
| Args: | |
| cookie_string: A cookie string. | |
| Returns: | |
| A string keyed dictionary of values | |
| """ | |
| cookies = [cookie.split("=", 1) if "=" in cookie else ("", cookie) for cookie in cookie_string.split(";")] | |
| output: dict[str, str] = { | |
| k: unquote(unquote_cookie(v)) | |
| for k, v in filter( | |
| lambda x: x[0] or x[1], | |
| ((k.strip(), v.strip()) for k, v in cookies), | |
| ) | |
| } | |
| return output |
MCVE
No response
Steps to reproduce
No response
Screenshots
No response
Logs
No response
Litestar Version
v2.5.1
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)
Metadata
Metadata
Assignees
Labels
Bug 🐛This is something that is not working as expectedThis is something that is not working as expected
Type
Projects
Status
Triage