areguera / rpms / mailman

Forked from rpms/mailman 5 years ago
Clone

Blame SOURCES/mailman-2_1-xss_vulnerability.patch

9e479e
diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py
9e479e
index 9a2389a..ae701a7 100644
9e479e
--- a/Mailman/Cgi/options.py
9e479e
+++ b/Mailman/Cgi/options.py
9e479e
@@ -18,6 +18,7 @@
9e479e
 """Produce and handle the member options."""
9e479e
 
9e479e
 import sys
9e479e
+import re
9e479e
 import os
9e479e
 import cgi
9e479e
 import signal
9e479e
@@ -149,19 +150,6 @@ def main():
9e479e
     doc.set_language(userlang)
9e479e
     i18n.set_language(userlang)
9e479e
 
9e479e
-    # See if this is VARHELP on topics.
9e479e
-    varhelp = None
9e479e
-    if cgidata.has_key('VARHELP'):
9e479e
-        varhelp = cgidata['VARHELP'].value
9e479e
-    elif os.environ.get('QUERY_STRING'):
9e479e
-        # POST methods, even if their actions have a query string, don't get
9e479e
-        # put into FieldStorage's keys :-(
9e479e
-        qs = cgi.parse_qs(os.environ['QUERY_STRING']).get('VARHELP')
9e479e
-        if qs and type(qs) == types.ListType:
9e479e
-            varhelp = qs[0]
9e479e
-    if varhelp:
9e479e
-        topic_details(mlist, doc, user, cpuser, userlang, varhelp)
9e479e
-        return
9e479e
 
9e479e
     # Are we processing an unsubscription request from the login screen?
9e479e
     if cgidata.has_key('login-unsub'):
9e479e
@@ -261,6 +249,22 @@ def main():
9e479e
         print doc.Format()
9e479e
         return
9e479e
 
9e479e
+    # See if this is VARHELP on topics.
9e479e
+    varhelp = None
9e479e
+    if cgidata.has_key('VARHELP'):
9e479e
+        varhelp = cgidata['VARHELP'].value
9e479e
+    elif os.environ.get('QUERY_STRING'):
9e479e
+        # POST methods, even if their actions have a query string, don't get
9e479e
+        # put into FieldStorage's keys :-(
9e479e
+        qs = cgi.parse_qs(os.environ['QUERY_STRING']).get('VARHELP')
9e479e
+        if qs and type(qs) == types.ListType:
9e479e
+            varhelp = qs[0]
9e479e
+    if varhelp:
9e479e
+        # Sanitize the topic name.
9e479e
+        varhelp = re.sub('<.*', '', varhelp)
9e479e
+        topic_details(mlist, doc, user, cpuser, userlang, varhelp)
9e479e
+        return
9e479e
+
9e479e
     # From here on out, the user is okay to view and modify their membership
9e479e
     # options.  The first set of checks does not require the list to be
9e479e
     # locked.