diff options
author | Yasuhito FUTATSUKI at POEM <futatuki@poem.co.jp> | 2018-01-30 13:52:57 +0900 |
---|---|---|
committer | Yasuhito FUTATSUKI at POEM <futatuki@poem.co.jp> | 2018-01-30 13:52:57 +0900 |
commit | c0e8bb68ec685ac9e38e1993b4054d4707486bf9 (patch) | |
tree | 79bc7ae61f91d9ccdf417896085ddb844fcb74e2 /Mailman/Cgi/subscribe.py | |
parent | f74c636bcb6d03b269d65a3b4d6ec3af835dca62 (diff) | |
parent | c88ce52f7177f5cf5d56bf3786c90f5c9e679d04 (diff) | |
download | mailman2-c0e8bb68ec685ac9e38e1993b4054d4707486bf9.tar.gz mailman2-c0e8bb68ec685ac9e38e1993b4054d4707486bf9.tar.xz mailman2-c0e8bb68ec685ac9e38e1993b4054d4707486bf9.zip |
sync with lp:mailman/2.1 Rev 1738
Diffstat (limited to 'Mailman/Cgi/subscribe.py')
-rwxr-xr-x | Mailman/Cgi/subscribe.py | 24 |
1 files changed, 23 insertions, 1 deletions
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()) |