--- listinfo.py 2018-02-26 14:56:48.000000000 +0000
+++ /usr/lib/mailman/Mailman/Cgi/listinfo.py 2018-02-26 14:08:34.000000000 +0000
@@ -31,6 +31,7 @@
from Mailman import i18n
from Mailman.htmlformat import *
from Mailman.Logging.Syslog import syslog
+from recaptcha.client import captcha
# Set up i18n
_ = i18n._
@@ -244,6 +245,10 @@
replacements[''] = mlist.FormatFormStart('listinfo')
replacements[''] = mlist.FormatBox('fullname', size=30)
+ # Captcha
+ replacements['<mm-recaptcha-javascript>'] = captcha.displayhtml(mm_cfg.RECAPTCHA_PUBLIC_KEY, use_ssl=True, version=2)
+ replacements['<mm-recaptcha-script>'] = captcha.load_script(version=2)
+
# Do the expansion.
doc.AddItem(mlist.ParseTags('listinfo.html', replacements, lang))
print doc.Format()
--- subscribe.py 2018-02-26 14:56:38.000000000 +0000
+++ /usr/lib/mailman/Mailman/Cgi/subscribe.py 2018-02-26 14:08:18.000000000 +0000
@@ -32,6 +32,7 @@
from Mailman.UserDesc import UserDesc
from Mailman.htmlformat import *
from Mailman.Logging.Syslog import syslog
+from recaptcha.client import captcha
SLASH = '/'
ERRORSEP = '\n\n<p>'
@@ -165,6 +166,17 @@
results.append(
_('There was no hidden token in your submission or it was corrupted.'))
results.append(_('You must GET the form before submitting it.'))
+
+ # recaptcha
+ captcha_response = captcha.v2submit(
+ cgidata.getvalue('g-recaptcha-response', ""),
+ mm_cfg.RECAPTCHA_PRIVATE_KEY,
+ remote,
+ )
+
+ if not captcha_response.is_valid:
+ results.append(_('Invalid captcha: %s' % captcha_response.error_code))
+
# Was an attempt made to subscribe the list to itself?
if email == mlist.GetListEmail():
syslog('mischief', 'Attempt to self subscribe %s: %s', email, remote)