diff options
43 files changed, 109 insertions, 4 deletions
diff --git a/Mailman/Cgi/listinfo.py b/Mailman/Cgi/listinfo.py index b8704486..bab460b6 100644 --- a/Mailman/Cgi/listinfo.py +++ b/Mailman/Cgi/listinfo.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2017 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 @@ -21,6 +21,7 @@ # No lock needed in this script, because we don't change data. import os +import re import cgi import time @@ -243,6 +244,18 @@ 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) + # If reCAPTCHA is enabled, display its user interface + if mm_cfg.RECAPTCHA_SITE_KEY: + rlang = re.sub('_', '-', lang) + replacements['<mm-recaptcha-ui>'] = ( + """<tr><td> </td><td> + <script src="https://www.google.com/recaptcha/api.js?hl=%s"> + </script> + <div class="g-recaptcha" data-sitekey="%s"></div> + </td></tr>""" + % (rlang, mm_cfg.RECAPTCHA_SITE_KEY)) + else: + replacements['<mm-recaptcha-ui>'] = '' # Do the expansion. doc.AddItem(mlist.ParseTags('listinfo.html', replacements, lang)) diff --git a/Mailman/Cgi/subscribe.py b/Mailman/Cgi/subscribe.py index 232048d7..301d1733 100755 --- a/Mailman/Cgi/subscribe.py +++ b/Mailman/Cgi/subscribe.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2017 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 @@ -22,6 +22,9 @@ import os import cgi import time import signal +import urllib +import urllib2 +import json from Mailman import mm_cfg from Mailman import Utils @@ -131,6 +134,25 @@ def process_form(mlist, doc, cgidata, lang): os.environ.get('HTTP_X_FORWARDED_FOR', os.environ.get('REMOTE_ADDR', 'unidentified origin'))) + + # Check reCAPTCHA submission, if enabled + if mm_cfg.RECAPTCHA_SECRET_KEY: + request = urllib2.Request( + url = 'https://www.google.com/recaptcha/api/siteverify', + data = urllib.urlencode({ + 'secret': mm_cfg.RECAPTCHA_SECRET_KEY, + 'response': cgidata.getvalue('g-recaptcha-response', ''), + 'remoteip': remote})) + try: + httpresp = urllib2.urlopen(request) + captcha_response = json.load(httpresp) + httpresp.close() + if not captcha_response['success']: + results.append(_('reCAPTCHA validation failed: %s' % + ', '.join(captcha_response['error-codes']))) + except urllib2.URLError as e: + results.append(_('reCAPTCHA could not be validated: %s' % e.reason)) + # Are we checking the hidden data? if mm_cfg.SUBSCRIBE_FORM_SECRET: now = int(time.time()) diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in index 309d0ba3..4406a1f3 100755 --- a/Mailman/Defaults.py.in +++ b/Mailman/Defaults.py.in @@ -1,6 +1,6 @@ # -*- python -*- -# Copyright (C) 1998-2017 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 @@ -131,6 +131,12 @@ SUBSCRIBE_FORM_SECRET = None # test. SUBSCRIBE_FORM_MIN_TIME = seconds(5) +# Use Google reCAPTCHA to protect the subscription form from spam bots. The +# following must be set to a pair of keys issued by the reCAPTCHA service at +# https://www.google.com/recaptcha/admin +RECAPTCHA_SITE_KEY = None +RECAPTCHA_SECRET_KEY = None + # Installation wide ban list. This is a list of email addresses and regexp # patterns (beginning with ^) which are not allowed to subscribe to any lists # in the installation. This supplements the individual list's ban_list. @@ -1,6 +1,6 @@ -*- coding: iso-8859-1 -*- Mailman - The GNU Mailing List Management System -Copyright (C) 1998-2017 by the Free Software Foundation, Inc. +Copyright (C) 1998-2018 by the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Here is a history of user visible changes to Mailman. @@ -9,6 +9,13 @@ Here is a history of user visible changes to Mailman. New Features + - Thanks to David Siebrger who adapted an existing patch by Andrea + Veri to use Google reCAPTCHA v2 there is now the ability to add + reCAPTCHA to the listinfo subscribe form. There are two new mm_cfg.py + settings for RECAPTCHA_SITE_KEY and RECAPTCHA_SECRET_KEY, the values + for which you obtain for your domain(s) from Google at + <https://www.google.com/recaptcha/admin>. + - Thanks to Lindsay Haisley, there is a new bin/mailman-config command to display various information about this Mailman version and how it was configured. diff --git a/templates/ar/listinfo.html b/templates/ar/listinfo.html index 10e870f8..8a24e75c 100644 --- a/templates/ar/listinfo.html +++ b/templates/ar/listinfo.html @@ -111,6 +111,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/ast/listinfo.html b/templates/ast/listinfo.html index 838e119b..f451a1b1 100644 --- a/templates/ast/listinfo.html +++ b/templates/ast/listinfo.html @@ -103,6 +103,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></P></center> diff --git a/templates/ca/listinfo.html b/templates/ca/listinfo.html index 174560d8..f1a66f7c 100644 --- a/templates/ca/listinfo.html +++ b/templates/ca/listinfo.html @@ -114,6 +114,7 @@ que es mostrin els vostres missatges?</TD> </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/cs/listinfo.html b/templates/cs/listinfo.html index 8ed7f1a2..408b22b5 100644 --- a/templates/cs/listinfo.html +++ b/templates/cs/listinfo.html @@ -112,6 +112,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/da/listinfo.html b/templates/da/listinfo.html index 999048ef..79cf9d47 100644 --- a/templates/da/listinfo.html +++ b/templates/da/listinfo.html @@ -108,6 +108,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/de/listinfo.html b/templates/de/listinfo.html index 75dce30f..647a66cc 100755 --- a/templates/de/listinfo.html +++ b/templates/de/listinfo.html @@ -114,6 +114,7 @@ Liste <MM-List-Name></MM-Archive>. <MM-Restricted-List-Message> </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/el/listinfo.html b/templates/el/listinfo.html index f66fb7fe..65455594 100755 --- a/templates/el/listinfo.html +++ b/templates/el/listinfo.html @@ -116,6 +116,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></P></center> diff --git a/templates/en/listinfo.html b/templates/en/listinfo.html index f02b170d..c3c216b1 100644 --- a/templates/en/listinfo.html +++ b/templates/en/listinfo.html @@ -115,6 +115,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/es/listinfo.html b/templates/es/listinfo.html index a06b7f56..c73d9d0e 100644 --- a/templates/es/listinfo.html +++ b/templates/es/listinfo.html @@ -107,6 +107,7 @@ <TD BGCOLOR="#dddddd">¿En qué idioma desea visualizar sus mensajes?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>¿Desea recibir los mensaje de cada día reunidos en un único mensaje (digest)? @@ -115,6 +116,8 @@ <MM-Digest-Radio-Button> Sí </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/et/listinfo.html b/templates/et/listinfo.html index 361c880a..b6967d9e 100644 --- a/templates/et/listinfo.html +++ b/templates/et/listinfo.html @@ -98,6 +98,7 @@ <TD BGCOLOR="#dddddd">Kasutajaliidese keel?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>Kirju saadetakse kokkuvõtetena </td> @@ -105,6 +106,8 @@ <MM-Digest-Radio-Button> Jah </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/eu/listinfo.html b/templates/eu/listinfo.html index 7b6ffb98..a6a8a769 100644 --- a/templates/eu/listinfo.html +++ b/templates/eu/listinfo.html @@ -113,6 +113,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/fa/listinfo.html b/templates/fa/listinfo.html index 53dd0b32..80422928 100644 --- a/templates/fa/listinfo.html +++ b/templates/fa/listinfo.html @@ -105,6 +105,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/fi/listinfo.html b/templates/fi/listinfo.html index 5d99ce00..a52da14c 100644 --- a/templates/fi/listinfo.html +++ b/templates/fi/listinfo.html @@ -110,6 +110,7 @@ <TD BGCOLOR="#dddddd">Millä kielellä haluat ohjeet ja lomakkeet?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>Haluatko vastaanottaa listan viestit päivittäisenä kokoelmana yksittäisten viestien sijaan? @@ -118,6 +119,8 @@ <MM-Digest-Radio-Button> Kyllä </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/fr/listinfo.html b/templates/fr/listinfo.html index 4c91c35c..61954769 100644 --- a/templates/fr/listinfo.html +++ b/templates/fr/listinfo.html @@ -118,6 +118,7 @@ </td> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/gl/listinfo.html b/templates/gl/listinfo.html index 2297f249..7f65048b 100644 --- a/templates/gl/listinfo.html +++ b/templates/gl/listinfo.html @@ -106,6 +106,7 @@ <TD BGCOLOR="#dddddd">En que idioma desexa ver as mensaxes?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>Desexa recibir as mensaxes diarias compiladas nunha única mensaxe? @@ -114,6 +115,8 @@ <MM-Digest-Radio-Button> Si </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/he/listinfo.html b/templates/he/listinfo.html index 3f6113c1..dc5bca26 100644 --- a/templates/he/listinfo.html +++ b/templates/he/listinfo.html @@ -110,6 +110,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/hr/listinfo.html b/templates/hr/listinfo.html index 5b46a913..37de789e 100644 --- a/templates/hr/listinfo.html +++ b/templates/hr/listinfo.html @@ -112,6 +112,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/hu/listinfo.html b/templates/hu/listinfo.html index 6d3d6992..4f62722f 100644 --- a/templates/hu/listinfo.html +++ b/templates/hu/listinfo.html @@ -111,6 +111,7 @@ </tr> <tr> <mm-digest-question-end> + <mm-recaptcha-ui> <td colspan="3"> <center><MM-Subscribe-Button></center> </td> diff --git a/templates/ia/listinfo.html b/templates/ia/listinfo.html index d266e3b5..c0077505 100644 --- a/templates/ia/listinfo.html +++ b/templates/ia/listinfo.html @@ -103,6 +103,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/it/listinfo.html b/templates/it/listinfo.html index 24617830..deb68063 100644 --- a/templates/it/listinfo.html +++ b/templates/it/listinfo.html @@ -123,6 +123,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/ja/listinfo.html b/templates/ja/listinfo.html index 95507f61..dfe50760 100644 --- a/templates/ja/listinfo.html +++ b/templates/ja/listinfo.html @@ -115,6 +115,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/ko/listinfo.html b/templates/ko/listinfo.html index 41463dff..13805662 100644 --- a/templates/ko/listinfo.html +++ b/templates/ko/listinfo.html @@ -103,6 +103,7 @@ <TD BGCOLOR="#dddddd"> ϼ?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td> Ϸ翡 ƺ Ͻðڽϱ? </td> @@ -110,6 +111,8 @@ <MM-Digest-Radio-Button> </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/lt/listinfo.html b/templates/lt/listinfo.html index 1c8c71ab..fb95229f 100644 --- a/templates/lt/listinfo.html +++ b/templates/lt/listinfo.html @@ -104,6 +104,7 @@ <TD BGCOLOR="#dddddd">Pasirinkite kalb?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>Ar norite gauti dienos laišk rinkinius? </td> @@ -111,6 +112,8 @@ <MM-Digest-Radio-Button> Taip </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/nl/listinfo.html b/templates/nl/listinfo.html index 48d57cc0..65eb4f7d 100644 --- a/templates/nl/listinfo.html +++ b/templates/nl/listinfo.html @@ -99,6 +99,7 @@ <TD BGCOLOR="#dddddd">Wat is uw voorkeurstaal voor de berichten?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>Wilt u de berichten gebundeld ontvangen in een dagelijkse verzamelmail? </td> @@ -106,6 +107,8 @@ <MM-Digest-Radio-Button> Ja </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/no/listinfo.html b/templates/no/listinfo.html index fdd1593d..90468069 100644 --- a/templates/no/listinfo.html +++ b/templates/no/listinfo.html @@ -108,6 +108,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/pl/listinfo.html b/templates/pl/listinfo.html index e02e3ea4..457a83b2 100644 --- a/templates/pl/listinfo.html +++ b/templates/pl/listinfo.html @@ -113,6 +113,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/pt/listinfo.html b/templates/pt/listinfo.html index a958455e..5b6e8e6f 100644 --- a/templates/pt/listinfo.html +++ b/templates/pt/listinfo.html @@ -114,6 +114,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/pt_BR/listinfo.html b/templates/pt_BR/listinfo.html index a9124259..026f29fd 100644 --- a/templates/pt_BR/listinfo.html +++ b/templates/pt_BR/listinfo.html @@ -105,6 +105,7 @@ <TD BGCOLOR="#dddddd">Em que idioma prefere exibir suas mensagens?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>Deseja receber e-mails da lista enviados uma vez por dia em um único email (digest)? @@ -113,6 +114,8 @@ <MM-Digest-Radio-Button> Sim </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/ro/listinfo.html b/templates/ro/listinfo.html index 5aa916bc..8fedf57c 100644 --- a/templates/ro/listinfo.html +++ b/templates/ro/listinfo.html @@ -109,6 +109,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/ru/listinfo.html b/templates/ru/listinfo.html index 27f0de47..87f4b12d 100644 --- a/templates/ru/listinfo.html +++ b/templates/ru/listinfo.html @@ -100,6 +100,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/sk/listinfo.html b/templates/sk/listinfo.html index 81a7b738..0e9e2bea 100644 --- a/templates/sk/listinfo.html +++ b/templates/sk/listinfo.html @@ -117,6 +117,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/sl/listinfo.html b/templates/sl/listinfo.html index 551ad268..a6d3108e 100644 --- a/templates/sl/listinfo.html +++ b/templates/sl/listinfo.html @@ -112,6 +112,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/sr/listinfo.html b/templates/sr/listinfo.html index d884f5a3..d4f601a7 100644 --- a/templates/sr/listinfo.html +++ b/templates/sr/listinfo.html @@ -97,6 +97,7 @@ <td><MM-Undigest-Radio-Button> Не<MM-Digest-Radio-Button> Да</TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center> <MM-Subscribe-Button></center> diff --git a/templates/sv/listinfo.html b/templates/sv/listinfo.html index 38e78dc9..d2824096 100644 --- a/templates/sv/listinfo.html +++ b/templates/sv/listinfo.html @@ -94,6 +94,7 @@ <td><MM-Undigest-Radio-Button> Nej <MM-Digest-Radio-Button> Ja </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/tr/listinfo.html b/templates/tr/listinfo.html index da7b935c..8d7fdf3a 100644 --- a/templates/tr/listinfo.html +++ b/templates/tr/listinfo.html @@ -115,6 +115,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/uk/listinfo.html b/templates/uk/listinfo.html index 3ee3bdfb..b881ff3a 100644 --- a/templates/uk/listinfo.html +++ b/templates/uk/listinfo.html @@ -111,6 +111,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/vi/listinfo.html b/templates/vi/listinfo.html index b4627b38..5b864d3e 100644 --- a/templates/vi/listinfo.html +++ b/templates/vi/listinfo.html @@ -102,6 +102,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/zh_CN/listinfo.html b/templates/zh_CN/listinfo.html index 98bc3a76..c329aa27 100644 --- a/templates/zh_CN/listinfo.html +++ b/templates/zh_CN/listinfo.html @@ -107,6 +107,7 @@ </TD> </tr> <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> diff --git a/templates/zh_TW/listinfo.html b/templates/zh_TW/listinfo.html index d19d2931..dd066425 100644 --- a/templates/zh_TW/listinfo.html +++ b/templates/zh_TW/listinfo.html @@ -91,6 +91,7 @@ HREF="mailto:<MM-Posting-Addr>"><MM-Posting-Addr></A>。 <TD BGCOLOR="#dddddd"> 您適用的語言?</TD> <TD> <MM-list-langs></TD> <TD> </TD></TR> + <mm-digest-question-start> <tr> <td>你 想 以 每 日 摘 要 的 形 式 收 信 嗎 ? </td> @@ -98,6 +99,8 @@ HREF="mailto:<MM-Posting-Addr>"><MM-Posting-Addr></A>。 <MM-Digest-Radio-Button> Yes </TD> </tr> + <mm-digest-question-end> + <mm-recaptcha-ui> <tr> <td colspan="3"> <center><MM-Subscribe-Button></center> |