diff roundup/cgi/client.py @ 8580:5cba36e42b8f

chore: refactor replace urlparse with urlsplit and use urllib_ Python docs recommend use of urlsplit() rather than urlparse(). urlsplit() is a little faster and doesn't try to split the path into path and params using the rules from an obsolete RFC. actions.py, demo.py, rest.py, client.py Replace urlparse() with urlsplit() actions.py urlsplit() produces a named tuple with one fewer elements (no .param). So fixup calls to urlunparse() so they have the proper number of elements in the tuple. also merge url filtering for param and path. demo.py, rest.py: Replace imports from urlparse/urllib.parse with roundup.anypy.urllib_ so we use the same interface throughout the code base. test/test_cgi.py: Since actions.py filtering for invali urls not split by path/param, fix tests for improperly quoted url's.
author John Rouillard <rouilj@ieee.org>
date Sun, 19 Apr 2026 22:58:59 -0400
parents ed1465c5963e
children 20b2833056f3
line wrap: on
line diff
--- a/roundup/cgi/client.py	Sun Apr 19 22:51:54 2026 -0400
+++ b/roundup/cgi/client.py	Sun Apr 19 22:58:59 2026 -0400
@@ -489,7 +489,7 @@
 
         # this is the "cookie path" for this tracker (ie. the path part of
         # the "base" url)
-        self.cookie_path = urllib_.urlparse(self.base)[2]
+        self.cookie_path = urllib_.urlsplit(self.base)[2]
         # cookies to set in http responce
         # {(path, name): (value, expire)}
         self._cookies = {}
@@ -1465,7 +1465,7 @@
     def is_referer_header_ok(self, api=False):
         referer = self.env['HTTP_REFERER']
         # parse referer and create an origin
-        referer_comp = urllib_.urlparse(referer)
+        referer_comp = urllib_.urlsplit(referer)
 
         # self.base always has trailing /, so add trailing / to referer_origin
         referer_origin = "%s://%s/" % (referer_comp[0], referer_comp[1])

Roundup Issue Tracker: http://roundup-tracker.org/