mitmproxy/test/mitmproxy
Lucas Ficheux 43bbcefd1e
Parse set header cookies properly (#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>
2023-12-02 11:21:38 +07:00
..
addons Add option to return various status codes rather than killing during server replay (#6465) 2023-11-08 11:12:44 +01:00
completion
contentviews Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
coretypes Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
data Fix case that causes corrupt har files to be written (#6459) 2023-11-06 07:31:28 -08:00
io Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
net Parse set header cookies properly (#5084) 2023-12-02 11:21:38 +07:00
platform
proxy Rename: osproxy -> local redirector (#6453) 2023-11-04 10:52:18 +00:00
script
tools Add option to return various status codes rather than killing during server replay (#6465) 2023-11-08 11:12:44 +01:00
utils fix #6426 - Optimize LDAP Proxy Auth (#6428) 2023-10-31 12:52:21 +00:00
__init__.py
test_addonmanager.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
test_certs.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
test_command.py
test_command_lexer.py
test_connection.py
test_ctx.py
test_dns.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
test_eventsequence.py
test_exceptions.py
test_flow.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
test_flowfilter.py
test_hooks.py
test_http.py Parse set header cookies properly (#5084) 2023-12-02 11:21:38 +07:00
test_log.py
test_master.py
test_options.py
test_optmanager.py
test_proxy.py
test_taddons.py
test_tcp.py
test_tls.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
test_typemanager.py
test_types.py Migrate to ruff (#6433) 2023-10-31 16:03:53 +01:00
test_udp.py
test_version.py
test_websocket.py