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
{{ message }}
Repository navigation
http.cookies: SimpleCookie silently drops cookies containing standard 'Partitioned' attribute #162126
When parsing cookie headers with the modern Partitioned attribute (CHIPS / RFC 6265bis, supported across all major web browsers and modern web frameworks), http.cookies.SimpleCookie silently discards the entire cookie. In addition, attempting to set morsel['partitioned'] = True raises CookieError: Invalid attribute 'partitioned'.
Reproduction:
fromhttpimportcookies# 1. Loading a cookie with the Partitioned flagc1=cookies.SimpleCookie()
c1.load('session=12345; Secure; SameSite=None; Partitioned')
print('Cookies loaded (with Partitioned):', len(c1))
# Output: Cookies loaded (with Partitioned): 0 (silently dropped!)# 2. Same cookie without Partitionedc2=cookies.SimpleCookie()
c2.load('session=12345; Secure; SameSite=None')
print('Cookies loaded (without Partitioned):', len(c2))
# Output: Cookies loaded (without Partitioned): 1# 3. Attempting to set Partitioned attribute programmaticallyc3=cookies.SimpleCookie()
c3['session'] ='12345'try:
c3['session']['partitioned'] =Trueexceptcookies.CookieErrorase:
print('Error setting partitioned:', e)
# Output: Error setting partitioned: Invalid attribute 'partitioned'
Actual Behavior:
Because 'partitioned' is not present in Morsel._reserved and Morsel._flags, when _BaseCookie.__parse_string encounters Partitioned, it hits the valueless-token fallback:
This triggers the early return and causes SimpleCookie to discard the entire cookie header without loading any morsels.
Expected Behavior:
Partitioned should be recognized as a valid boolean flag attribute (like Secure and HttpOnly), allowing modern partitioned cookies to be parsed without dropping the cookie, and serialized as ; Partitioned.
Activity