r5481 - trunk/wooly/python/wooly

tmckay at fedoraproject.org tmckay at fedoraproject.org
Wed Sep 26 21:35:33 UTC 2012


Author: tmckay
Date: 2012-09-26 21:35:31 +0000 (Wed, 26 Sep 2012)
New Revision: 5481

Modified:
   trunk/wooly/python/wooly/__init__.py
Log:
Difference in return result of urlparse.urlparse requires hardwired indices
BZ847940


Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py	2012-09-26 21:06:23 UTC (rev 5480)
+++ trunk/wooly/python/wooly/__init__.py	2012-09-26 21:35:31 UTC (rev 5481)
@@ -540,6 +540,15 @@
 
     def validate_redirect(self, session, url, env):
 
+        # Sigh, urlparse returns a different result in Python 2.4 and
+        # Python 2.6 so we have to index ourselves.
+        SCHEME   = 0
+        NETLOC   = 1
+        PATH     = 2
+        PARAMS   = 3
+        QUERY    = 4
+        FRAGMENT = 5
+
         def netloc(env):
             if 'HTTP_HOST' in env:
                 return env['HTTP_HOST']
@@ -549,13 +558,13 @@
         if type(url) in (str, unicode):
             res = urlparse.urlparse(url)
             # Path will be an index into our dictionary of pages
-            p = res.path
+            p = res[PATH]
             if p.startswith("/"):
                 p = p[1:]
 
             if not p in self.app.pages_by_name or \
-               (res.scheme and res.scheme != env['wsgi.url_scheme']) or \
-               (res.netloc and res.netloc != netloc(env)):
+               (res[SCHEME] and res[SCHEME] != env['wsgi.url_scheme']) or \
+               (res[NETLOC] and res[NETLOC] != netloc(env)):
                 session.add_notice(Notice("Invalid redirect, " \
                                           "returning to main page"))
                 url = self.lookup_mainpage(session)



More information about the cumin-developers mailing list