clean up some old task
[ansible.git] / roles / email / files / mailman-patched / Cgi / listinfo.py
index 0ce6393f5b3d8343e7634f1754cd2f26827d4e93..0e38d03c71143b48e08b72a497b6e11a711d89fb 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2018 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -38,8 +38,7 @@ _ = i18n._
 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
 
 
 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
 
 
-
-
+\f
 def main():
     parts = Utils.GetPathPieces()
     if not parts:
 def main():
     parts = Utils.GetPathPieces()
     if not parts:
@@ -61,7 +60,7 @@ def main():
     # See if the user want to see this page in other language
     cgidata = cgi.FieldStorage()
     try:
     # See if the user want to see this page in other language
     cgidata = cgi.FieldStorage()
     try:
-        language = cgidata.getvalue('language')
+        language = cgidata.getfirst('language')
     except TypeError:
         # Someone crafted a POST with a bad Content-Type:.
         doc = Document()
     except TypeError:
         # Someone crafted a POST with a bad Content-Type:.
         doc = Document()
@@ -79,8 +78,7 @@ def main():
     list_listinfo(mlist, language)
 
 
     list_listinfo(mlist, language)
 
 
-
-
+\f
 def listinfo_overview(msg=''):
     # Present the general listinfo overview
     hostname = Utils.get_domain()
 def listinfo_overview(msg=''):
     # Present the general listinfo overview
     hostname = Utils.get_domain()
@@ -117,7 +115,7 @@ def listinfo_overview(msg=''):
             else:
                 advertised.append((mlist.GetScriptURL('listinfo'),
                                    mlist.real_name,
             else:
                 advertised.append((mlist.GetScriptURL('listinfo'),
                                    mlist.real_name,
-                                   Utils.websafe(mlist.description)))
+                                   Utils.websafe(mlist.GetDescription())))
     if msg:
         greeting = FontAttr(msg, color="ff5060", size="+1")
     else:
     if msg:
         greeting = FontAttr(msg, color="ff5060", size="+1")
     else:
@@ -175,8 +173,7 @@ def listinfo_overview(msg=''):
     print doc.Format()
 
 
     print doc.Format()
 
 
-
-
+\f
 def list_listinfo(mlist, lang):
     # Generate list specific listinfo
     doc = HeadlessDocument()
 def list_listinfo(mlist, lang):
     # Generate list specific listinfo
     doc = HeadlessDocument()
@@ -221,16 +218,16 @@ def list_listinfo(mlist, lang):
             #        for our hash so it doesn't matter.
             remote = remote.rsplit(':', 1)[0]
         # get CAPTCHA data
             #        for our hash so it doesn't matter.
             remote = remote.rsplit(':', 1)[0]
         # get CAPTCHA data
-        (captcha_question, captcha_box, captcha_idx) = Captcha.displayhtml(mlist, mm_cfg.CAPTCHAS)
+        (captcha_question, captcha_box, captcha_idx) = Captcha.display(mlist, mm_cfg.CAPTCHAS)
         replacements['<mm-captcha-question>'] = captcha_question
         replacements['<mm-captcha-box>'] = captcha_box
         # fill form
         replacements['<mm-subscribe-form-start>'] += (
                 '<input type="hidden" name="sub_form_token" value="%s:%s:%s">\n'
         replacements['<mm-captcha-question>'] = captcha_question
         replacements['<mm-captcha-box>'] = captcha_box
         # fill form
         replacements['<mm-subscribe-form-start>'] += (
                 '<input type="hidden" name="sub_form_token" value="%s:%s:%s">\n'
-                % (now, captcha_idx, Utils.sha_new(mm_cfg.SUBSCRIBE_FORM_SECRET +
-                          now +
-                          captcha_idx +
-                          mlist.internal_name() +
+                % (now, captcha_idx, Utils.sha_new(mm_cfg.SUBSCRIBE_FORM_SECRET + ":" +
+                          now + ":" +
+                          captcha_idx + ":" +
+                          mlist.internal_name() + ":" +
                           remote
                           ).hexdigest()
                     )
                           remote
                           ).hexdigest()
                     )
@@ -253,13 +250,25 @@ def list_listinfo(mlist, lang):
     replacements['<mm-displang-box>'] = displang
     replacements['<mm-lang-form-start>'] = mlist.FormatFormStart('listinfo')
     replacements['<mm-fullname-box>'] = mlist.FormatBox('fullname', size=30)
     replacements['<mm-displang-box>'] = displang
     replacements['<mm-lang-form-start>'] = mlist.FormatFormStart('listinfo')
     replacements['<mm-fullname-box>'] = mlist.FormatBox('fullname', size=30)
+    # If reCAPTCHA is enabled, display its user interface
+    if mm_cfg.RECAPTCHA_SITE_KEY:
+        noscript = _('This form requires JavaScript.')
+        replacements['<mm-recaptcha-ui>'] = (
+            """<tr><td>&nbsp;</td><td>
+            <noscript>%s</noscript>
+            <script src="https://www.google.com/recaptcha/api.js?hl=%s">
+            </script>
+            <div class="g-recaptcha" data-sitekey="%s"></div>
+            </td></tr>"""
+            % (noscript, lang, mm_cfg.RECAPTCHA_SITE_KEY))
+    else:
+        replacements['<mm-recaptcha-ui>'] = ''
 
     # Do the expansion.
     doc.AddItem(mlist.ParseTags('listinfo.html', replacements, lang))
     print doc.Format()
 
 
 
     # Do the expansion.
     doc.AddItem(mlist.ParseTags('listinfo.html', replacements, lang))
     print doc.Format()
 
 
-
-
+\f
 if __name__ == "__main__":
     main()
 if __name__ == "__main__":
     main()