diff options
| -rw-r--r-- | Mailman/Cgi/admin.py | 4 | ||||
| -rw-r--r-- | Mailman/Cgi/admindb.py | 2 | ||||
| -rw-r--r-- | Mailman/Utils.py | 19 |
3 files changed, 22 insertions, 3 deletions
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py index 07589d2ab..371e1421e 100644 --- a/Mailman/Cgi/admin.py +++ b/Mailman/Cgi/admin.py @@ -119,12 +119,12 @@ def main(): is_auth = isAuthenticated(lst) message = "" if not is_auth: - defaulturi = 'mailman/admin%s/%s' % (mm_cfg.CGIEXT, list_name) + defaulturi = '/mailman/admin%s/%s' % (mm_cfg.CGIEXT, list_name) print "Content-type: text/html\n\n" text = Utils.maketext( 'admlogin.txt', {"listname": list_name, - "path" : os.environ.get("REQUEST_URI", defaulturi), + "path" : Utils.GetRequestURI(defaulturi), "message" : message, }) print text diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py index c38a1155d..7dfa00b58 100644 --- a/Mailman/Cgi/admindb.py +++ b/Mailman/Cgi/admindb.py @@ -113,7 +113,7 @@ def main(): text = Utils.maketext( 'admlogin.txt', {'listname': list_name, - 'path' : os.environ.get('REQUEST_URI', defaulturi), + 'path' : Utils.GetRequestURI(defaulturi), 'message' : message, }) print text diff --git a/Mailman/Utils.py b/Mailman/Utils.py index b9dc4a44b..d79d3543a 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -664,3 +664,22 @@ def open_ex(filename, mode='r', bufsize=-1, perms=0664): reraise(IOError, e) finally: os.umask(ou) + +def GetRequestURI(fallback=None): + """Return the full virtual path this CGI script was invoked with. + + Newer web servers seems to supply this info in the REQUEST_URI + environment variable -- which isn't part of the CGI/1.1 spec. + Thus, if REQUEST_URI isn't available, we concatenate SCRIPT_NAME + and PATH_INFO, both of which are part of CGI/1.1. + + Optional argument `fallback' (default `None') is returned if both of + the above methods fail. + + """ + if os.environ.has_key('REQUEST_URI'): + return os.environ['REQUEST_URI'] + elif os.environ.has_key('SCRIPT_NAME') and os.environ.has_key('PATH_INFO'): + return os.environ['SCRIPT_NAME'] + os.environ['PATH_INFO'] + else: + return fallback |
