[Mailman-Developers] Possible bug in 1.0b8
Harald Meland
Harald.Meland@usit.uio.no
22 Feb 1999 18:45:46 +0100
[Liam Kirsher]
> I found the problelm in
>
> Cgi/admindb.py, line 116
>
> the reference to /mailman/admindb/ was a problem.
> I think the "mailman" part should be gotten from the DEFAULT_URL,
> perhaps?
I don't think that DEFAULT_URL has anything to do with this problem --
the fix is rather related to not depending on the not-really-standard
(I think) REQUEST_URI environment variable.
Please bear in mind that this is the first time I'm trying to do any
CGI-related programming at all, but I still _think_ this patch is good
(from reading the CGI/1.1 spec, and testing quickly that it doesn't
break my web interface).
Index: Mailman/Utils.py
===================================================================
RCS file: /projects/cvsroot/mailman/Mailman/Utils.py,v
retrieving revision 1.62
diff -u -r1.62 Utils.py
--- Utils.py 1999/01/14 04:07:28 1.62
+++ Utils.py 1999/02/22 17:16:37
@@ -664,3 +664,20 @@
reraise(IOError, e)
finally:
os.umask(ou)
+
+def CGIpath(env):
+ """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. If that fails,
+ too, fall back to a hardcoded common case.
+
+ """
+ if env.has_key("REQUEST_URI"):
+ return env["REQUEST_URI"]
+ elif env.has_key("SCRIPT_NAME") and env.has_key("PATH_INFO"):
+ return (env["SCRIPT_NAME"] + env["PATH_INFO"])
+ else:
+ return ('/mailman/admin/' + list_name)
Index: Mailman/Cgi/admin.py
===================================================================
RCS file: /projects/cvsroot/mailman/Mailman/Cgi/admin.py,v
retrieving revision 1.31
diff -u -r1.31 admin.py
--- admin.py 1999/01/09 05:57:17 1.31
+++ admin.py 1999/02/22 17:16:38
@@ -123,8 +123,7 @@
text = Utils.maketext(
'admlogin.txt',
{"listname": list_name,
- "path" : os.environ.get("REQUEST_URI",
- '/mailman/admin/' + list_name),
+ "path" : Utils.CGIpath(os.environ),
"message" : message,
})
print text
Index: Mailman/Cgi/admindb.py
===================================================================
RCS file: /projects/cvsroot/mailman/Mailman/Cgi/admindb.py,v
retrieving revision 1.9
diff -u -r1.9 admindb.py
--- admindb.py 1999/01/09 06:22:44 1.9
+++ admindb.py 1999/02/22 17:16:38
@@ -112,8 +112,7 @@
text = Utils.maketext(
'admlogin.txt',
{'listname': list_name,
- 'path' : os.environ.get('REQUEST_URI',
- '/mailman/admindb/' + list_name),
+ 'path' : Utils.CGIpath(os.environ),
'message' : message,
})
print text
--
Harald