Ian Bicking avatar Ian Bicking committed ba6bf7b

Fix #443: url_unquote undefined

Comments (0)

Files changed (2)

 .. contents::
+hg tip
+* Fix bug introduced in :mod:`paste.auth.auth_tkt` (with ``url_unquote``)


 import Cookie
 from paste import request
 from urllib import quote as url_quote
+from urllib import unquote as url_unquote
 class AuthTicket(object):
             c[self.cookie_name]['secure'] = 'true'
         return c
 class BadTicket(Exception):
     Exception raised when a ticket can't be parsed.  If we get
         self.expected = expected
         Exception.__init__(self, msg)
 def parse_ticket(secret, ticket, ip):
     Parse the ticket, returning (timestamp, userid, tokens, user_data).
     return (timestamp, userid, tokens, user_data)
 def calculate_digest(ip, timestamp, secret, userid, tokens, user_data):
     secret = maybe_encode(secret)
     userid = maybe_encode(userid)
     digest = md5(digest0 + secret).hexdigest()
     return digest
 def encode_ip_timestamp(ip, timestamp):
     ip_chars = ''.join(map(chr, map(int, ip.split('.'))))
     t = int(timestamp)
     ts_chars = ''.join(map(chr, ts))
     return ip_chars + ts_chars
 def maybe_encode(s, encoding='utf8'):
     if isinstance(s, unicode):
         s = s.encode(encoding)
     return s
 class AuthTKTMiddleware(object):
     def __call__(self, environ, start_response):
         cookies = request.get_cookies(environ)
-        if cookies.has_key(self.cookie_name):
+        if self.cookie_name in cookies:
             cookie_value = cookies[self.cookie_name].value
             cookie_value = ''
                 # in or anything
         set_cookies = []
         def set_user(userid, tokens='', user_data=''):
                 environ, userid, tokens, user_data))
         def logout_user():
         environ['paste.auth_tkt.set_user'] = set_user
         environ['paste.auth_tkt.logout_user'] = logout_user
         if self.logout_path and environ.get('PATH_INFO') == self.logout_path:
         def cookie_setting_start_response(status, headers, exc_info=None):
             return start_response(status, headers, exc_info)
         return self.app(environ, cookie_setting_start_response)
     def set_user_cookie(self, environ, userid, tokens, user_data):
         return cookies
 def make_auth_tkt_middleware(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.