Skip to content

Commit e12135a

Browse files
author
Richard Jones
committed
possibly fix truncated base64'ed user:pass
1 parent aef2bf8 commit e12135a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

roundup/cgi_client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.45 2001-11-01 22:04:37 richard Exp $
18+
# $Id: cgi_client.py,v 1.46 2001-11-03 01:26:55 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
21-
import base64, Cookie, time
21+
import binascii, Cookie, time
2222

2323
import roundupdb, htmltemplate, date, hyperdb, password
2424

@@ -593,7 +593,7 @@ def login_action(self, message=None):
593593

594594
# construct the cookie
595595
uid = self.db.user.lookup(self.user)
596-
user = base64.encodestring('%s:%s'%(self.user, password))[:-1]
596+
user = binascii.b2a_base64('%s:%s'%(self.user, password)).strip()
597597
path = '/'.join((self.env['SCRIPT_NAME'], self.env['INSTANCE_NAME'],
598598
''))
599599
self.header({'Set-Cookie': 'roundup_user=%s; Path=%s;'%(user, path)})
@@ -633,7 +633,7 @@ def newuser_action(self, message=None):
633633
password = self.db.user.get(uid, 'password')
634634
# construct the cookie
635635
uid = self.db.user.lookup(self.user)
636-
user = base64.encodestring('%s:%s'%(self.user, password))[:-1]
636+
user = binascii.b2a_base64('%s:%s'%(self.user, password)).strip()
637637
path = '/'.join((self.env['SCRIPT_NAME'], self.env['INSTANCE_NAME'],
638638
''))
639639
self.header({'Set-Cookie': 'roundup_user=%s; Path=%s;'%(user, path)})
@@ -649,7 +649,7 @@ def main(self, dre=re.compile(r'([^\d]+)(\d+)'),
649649
if (cookie.has_key('roundup_user') and
650650
cookie['roundup_user'].value != 'deleted'):
651651
cookie = cookie['roundup_user'].value
652-
user, password = base64.decodestring(cookie).split(':')
652+
user, password = binascii.a2b_base64(cookie).split(':')
653653
# make sure the user exists
654654
try:
655655
uid = self.db.user.lookup(user)
@@ -876,6 +876,12 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
876876

877877
#
878878
# $Log: not supported by cvs2svn $
879+
# Revision 1.45 2001/11/01 22:04:37 richard
880+
# Started work on supporting a pop3-fetching server
881+
# Fixed bugs:
882+
# . bug #477104 ] HTML tag error in roundup-server
883+
# . bug #477107 ] HTTP header problem
884+
#
879885
# Revision 1.44 2001/10/28 23:03:08 richard
880886
# Added more useful header to the classic schema.
881887
#

0 commit comments

Comments
 (0)