classification
Title: Cookie.py does not correctly quote Morsels
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, zdobersek, zenzen (3)
Priority: normal Keywords patch

Created on 2004-07-15 00:17 by zenzen, last changed 2009-02-18 15:07 by ajaksu2.

Files
File name Uploaded Description Edit Remove
991266test.patch zdobersek, 2009-02-14 17:14 Patch to test_cookie.py
991266fix.patch zdobersek, 2009-02-18 14:40 Fix - properly quote cookie's comment
Messages (4)
msg60528 - (view) Author: Stuart Bishop (zenzen) Date: 2004-07-15 00:17
The quoting works fine for cookie values, but doesn't kick in for 
attributes like Comment. 

>>> c = SimpleCookie()
>>> c['foo'] = u'\N{COPYRIGHT SIGN}'.encode('UTF8')
>>> print str(c)
Set-Cookie: foo="\302\251";
>>> c['foo']['comment'] = u'\N{BIOHAZARD SIGN}'.encode('UTF8')
>>> print str(c)
Set-Cookie: foo="\302\251"; Comment=?;
>>> str(c)
'Set-Cookie: foo="\\302\\251"; Comment=\xe2\x98\xa3;'
>>> 
msg82094 - (view) Author: Zan Dobersek (zdobersek) Date: 2009-02-14 17:14
This patch adds an unicode character, converted to UTF8 as a cookie's
comment and then checks if it is correctly quoted.
msg82418 - (view) Author: Zan Dobersek (zdobersek) Date: 2009-02-18 14:40
This patch properly quotes cookie's comment and successfully passes
test_cookie.py with applied patch.
msg82420 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-18 15:07
Thanks, Zan!

All tests pass with both patches applied. Test and fix look correct to me.
History
Date User Action Args
2009-02-18 15:07:02ajaksu2setnosy: + ajaksu2
messages: + msg82420
stage: test needed -> patch review
2009-02-18 14:40:15zdoberseksetfiles: + 991266fix.patch
messages: + msg82418
2009-02-14 17:14:14zdoberseksetfiles: + 991266test.patch
keywords: + patch
messages: + msg82094
nosy: + zdobersek
2009-02-13 21:13:09jjleesetnosy: - jjlee
2009-02-13 01:18:53ajaksu2setnosy: + jjlee
stage: test needed
type: behavior
versions: + Python 2.6, - Python 2.3
2004-07-15 00:17:04zenzencreate