Skip to content

Commit 4d4a6e6

Browse files
author
Richard Jones
committed
another attempt to fix cookie misbehaviour
1 parent dbbde04 commit 4d4a6e6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ are given with the most recent entry first.
4343
return positive values..." (literal 0xffff0000 in portalocker.py)
4444
- fixed ZPT code generating SyntaxWarning for assignment to None
4545
- add "ago" to intervals in the past (sf bug 679232)
46+
- another attempt to fix cookie misbehaviour - customise cookie name using
47+
tracker name
4648

4749

4850
2003-??-?? 0.5.6

roundup/cgi/client.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.76 2003-02-06 05:43:47 richard Exp $
1+
# $Id: client.py,v 1.77 2003-02-07 04:49:13 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -95,6 +95,8 @@ def __init__(self, instance, request, env, form=None):
9595
# this is the "cookie path" for this tracker (ie. the path part of
9696
# the "base" url)
9797
self.cookie_path = urlparse.urlparse(self.base)[2]
98+
self.cookie_name = 'roundup_session_' + re.sub('[^a-zA-Z]', '',
99+
self.instance.config.TRACKER_NAME)
98100

99101
# see if we need to re-parse the environment for the form (eg Zope)
100102
if form is None:
@@ -227,11 +229,11 @@ def determine_user(self):
227229
user = 'anonymous'
228230

229231
# bump the "revision" of the cookie since the format changed
230-
if (cookie.has_key('roundup_user_2') and
231-
cookie['roundup_user_2'].value != 'deleted'):
232+
if (cookie.has_key(self.cookie_name) and
233+
cookie[self.cookie_name].value != 'deleted'):
232234

233235
# get the session key from the cookie
234-
self.session = cookie['roundup_user_2'].value
236+
self.session = cookie[self.cookie_name].value
235237
# get the user from the session
236238
try:
237239
# update the lifetime datestamp
@@ -486,8 +488,8 @@ def set_cookie(self, user):
486488

487489
# generate the cookie path - make sure it has a trailing '/'
488490
self.additional_headers['Set-Cookie'] = \
489-
'roundup_user_2=%s; expires=%s; Path=%s;'%(self.session, expire,
490-
self.cookie_path)
491+
'%s=%s; expires=%s; Path=%s;'%(self.cookie_name, self.session,
492+
expire, self.cookie_path)
491493

492494
def make_user_anonymous(self):
493495
''' Make us anonymous
@@ -583,8 +585,8 @@ def logout_action(self):
583585
# construct the logout cookie
584586
now = Cookie._getdate()
585587
self.additional_headers['Set-Cookie'] = \
586-
'roundup_user_2=deleted; Max-Age=0; expires=%s; Path=%s;'%(now,
587-
self.cookie_path)
588+
'%s=deleted; Max-Age=0; expires=%s; Path=%s;'%(self.cookie_name,
589+
now, self.cookie_path)
588590

589591
# Let the user know what's going on
590592
self.ok_message.append(_('You are logged out'))

0 commit comments

Comments
 (0)