Certain cookie flags don't get unpickled properly
|Reported by:||julien||Owned by:||julien|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I've noticed that some cookie flags (at least httponly and secure) do not properly get unpickled. This is an issue particularly for FetchFromCacheMiddleware when it unpickles a cached response object.
So far I've narrowed down the issue to this snippet of code:
import pickle from django.http import HttpResponse original = HttpResponse() original.set_cookie('foo', 'bar', path='/blah', httponly=True, secure=True) pickled = pickle.dumps(original, pickle.HIGHEST_PROTOCOL) reloaded = pickle.loads(pickled) # httponly and secure get lost in the pickle loading process!! original.cookies['foo']['httponly'] # True reloaded.cookies['foo']['httponly'] # '' original.cookies['foo']['secure'] # True reloaded.cookies['foo']['secure'] # '' str(original.cookies) # 'Set-Cookie: foo=bar; httponly; Path=/blah; secure' str(reloaded.cookies) # 'Set-Cookie: foo=bar; Path=/blah'
At this stage I'm unsure if it's a bug in Django or in Python. For the record, I've tested this with Python 2.7.5.
Change History (2)
comment:1 Changed 3 years ago by julien
- Owner changed from nobody to julien
- Status changed from new to assigned
- Triage Stage changed from Unreviewed to Accepted