--- client.py.orig 2007-06-18 01:55:09.000000000 -0400 +++ client.py 2007-06-18 01:55:51.000000000 -0400 @@ -5,10 +5,11 @@ __docformat__ = 'restructuredtext' import base64, binascii, cgi, codecs, mimetypes, os import random, re, rfc822, stat, time, urllib, urlparse import Cookie, socket, errno +from Cookie import CookieError, BaseCookie, SimpleCookie from roundup import roundupdb, date, hyperdb, password from roundup.cgi import templating, cgitb, TranslationService from roundup.cgi.actions import * from roundup.exceptions import * @@ -44,16 +45,39 @@ ''' if ok.has_key(match.group(3).lower()): return match.group(1) return '<%s>'%match.group(2) + error_message = ""'''An error has occurred

An error has occurred

A problem was encountered processing your request. The tracker maintainers have been notified of the problem.

''' + +class Cookie(SimpleCookie): + def load(self, rawdata, ignore_parse_errors=False): + if ignore_parse_errors: + self.bad_cookies = [] + self._BaseCookie__set = self._loose_set + SimpleCookie.load(self, rawdata) + if ignore_parse_errors: + self._BaseCookie__set = self._strict_set + for key in self.bad_cookies: + del self[key] + + _strict_set = BaseCookie._BaseCookie__set + + def _loose_set(self, key, real_value, coded_value): + try: + self._strict_set(key, real_value, coded_value) + except CookieError: + self.bad_cookies.append(key) + dict.__setitem__(self, key, None) + + class Client: '''Instantiate to handle one CGI request. See inner_main for request processing. @@ -161,11 +185,15 @@ # default character set self.charset = self.STORAGE_CHARSET # parse cookies (used in charset and session lookups) - self.cookie = Cookie.SimpleCookie(self.env.get('HTTP_COOKIE', '')) + cookie = self.env.get('HTTP_COOKIE', '') + self.cookie = Cookie() + if cookie: + self.cookie.load(cookie, ignore_parse_errors=True) + self.user = None self.userid = None self.nodeid = None self.classname = None