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``)
+
 1.7.5
 -----
 

paste/auth/auth_tkt.py

 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
         else:
             cookie_value = ''
                 # in or anything
                 pass
         set_cookies = []
+
         def set_user(userid, tokens='', user_data=''):
             set_cookies.extend(self.set_user_cookie(
                 environ, userid, tokens, user_data))
+
         def logout_user():
             set_cookies.extend(self.logout_user_cookie(environ))
+
         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:
             logout_user()
+
         def cookie_setting_start_response(status, headers, exc_info=None):
             headers.extend(set_cookies)
             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(
     app,
     global_conf,
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.