[Patches] [ python-Patches-1375011 ] Improper handling of duplicate cookies

SourceForge.net noreply at sourceforge.net
Thu Mar 15 00:54:50 CET 2007


Patches item #1375011, was opened at 2005-12-07 04:50
Message generated for change (Comment added) made by sonderblade
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1375011&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Viraj Alankar (valankar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improper handling of duplicate cookies

Initial Comment:
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.

----------------------------------------------------------------------

Comment By: Björn Lindqvist (sonderblade)
Date: 2007-03-15 00:54

Message:
Logged In: YES 
user_id=51702
Originator: NO

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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1375011&group_id=5470


More information about the Patches mailing list