classification
Title: Improper handling of duplicate cookies
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, ajaksu2, jjlee, sonderblade, valankar
Priority: normal Keywords: easy, patch

Created on 2005-12-07 03:50 by valankar, last changed 2010-08-22 01:33 by BreamoreBoy.

Files
File name Uploaded Description Edit
Cookie.py.patch valankar, 2005-12-07 03:50 Patch for revision 41632 of Cookie.py review
Messages (4)
msg49178 - (view) Author: Viraj Alankar (valankar) Date: 2005-12-07 03:50
This patch implements part of bug 1372650.

Sometimes a web client will send 2 instances of the same name:

Cookie: mycookie=foo; mycookie=bar

The specs listed here:

http://wp.netscape.com/newsref/std/cookie_spec.html

state that the first one is the one that should be used. The other 
cookies listed are the inherited ones from paths that a prefix of the 
current URL. When this is parsed by the Cookie module, mycookie gets 
set to bar when it should be foo.

This patch changes Cookie.py to only use the first instance of duplicate 
cookies when parsing cookie strings.
msg49179 - (view) Author: Björn Lindqvist (sonderblade) Date: 2007-03-14 23:54
That link is misleading and just confuses you. :) Instead read John J. Lee's great explanation at the referenced bug report. I have tested the patch and it works as expected. Without the patch:

>>> c = SimpleCookie('foo=33;foo=34')
>>> print c
Set-Cookie: foo=34

With the patch:

>>> c = SimpleCookie('foo=33;foo=34')
>>> print c
Set-Cookie: foo=33

There should be a unit test though and something in the documentation. The keys dict should be a set instead.
msg86297 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-04-22 14:42
See discussion in issue 1372650.
msg114634 - (view) Author: Mark Lawrence (BreamoreBoy) Date: 2010-08-22 01:33
Even if the patch is still valid there are still no doc or unit test changes.
History
Date User Action Args
2010-08-30 16:53:05BreamoreBoyunlinkissue1372650 dependencies
2010-08-30 16:53:05BreamoreBoylinkissue1372650 superseder
2010-08-22 01:33:46BreamoreBoysetnosy: + BreamoreBoy

messages: + msg114634
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-04-22 14:42:51ajaksu2setkeywords: + easy
nosy: + ajaksu2
messages: + msg86297

2009-02-16 03:57:53ajaksu2linkissue1372650 dependencies
2009-02-13 01:16:33ajaksu2setnosy: + jjlee
stage: test needed
type: behavior
versions: + Python 2.6, - Python 2.5
2005-12-07 03:50:53valankarcreate