forked from mitmproxy/mitmproxy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse set header cookies properly (mitmproxy#5084)
#### Description Currently when an empty cookie attribute (`Secure`, `HttpOnly` ...) is encountered while parsing a `Set-Cookie` header it will create a `CookieAttrs` object containing a (key, value) pair with an empty string for the attribute value ie: ```python CookieAttrs[('Secure', ''), ('HttpOnly', ''), ('Path', '/')] ``` Resulting in an updated `Set-Cookie` header for the `Response` object with invalid values for those empty attributes ie: ```python (b'SetCookie', b'value=XYZ; Secure=; HttpOnly=; Path=/') ``` My browser (Firefox 95.0.1) does not pickup these attributes so the cookie looses them. ______ This fix replaces the empty string attribute for empty cookie attributes by the value `None` ie: ```python CookieAttrs[('Secure', None), ('HttpOnly', None), ('Path', '/')] ``` So that they can be told apart from attributes with intentional empty string values when setting the updated header, which results in a properly formatted header: ```python (b'SetCookie', b'value=XYZ; Secure; HttpOnly; Path=/') ``` #### Checklist - [x] I have updated tests where applicable. - [x] I have added an entry to the CHANGELOG. Co-authored-by: Lucas FICHEUX <lficheux@corp.free.fr>
- Loading branch information
Showing
4 changed files
with
29 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters