Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/submit_email/web/submit_email.py

Issue 29326122: Issue 3015 - Remove legacy code for Adblock Browser from submit_email (Closed)
Patch Set: Created Sept. 8, 2015, 1:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sitescripts/submit_email/template/verification.mail ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/submit_email/web/submit_email.py
===================================================================
--- a/sitescripts/submit_email/web/submit_email.py
+++ b/sitescripts/submit_email/web/submit_email.py
@@ -19,6 +19,7 @@
import hmac
import hashlib
import wsgiref.util
+import ConfigParser
from urlparse import parse_qsl, urljoin
from urllib import urlencode, quote
@@ -26,7 +27,6 @@
from sitescripts.web import url_handler, form_handler, send_simple_response
VERIFICATION_PATH = '/verifyEmail'
-DEFAULT_PRODUCT = 'adblockbrowser'
def sign(config, data):
secret = config.get('submit_email', 'secret')
@@ -35,6 +35,14 @@
@url_handler('/submitEmail')
@form_handler
def submit_email(environ, start_response, data):
+ config = get_config()
+
+ try:
+ product = data['product']
+ template = config.get('submit_email', product + '_verification_email_template')
+ except (KeyError, ConfigParser.NoOptionError):
+ return send_simple_response(start_response, 400, 'Unkown product')
Felix Dahlke 2015/09/08 13:44:21 s/Unkown/Unknown?
Sebastian Noack 2015/09/08 14:09:43 Done.
+
email = data.get('email', '').strip()
try:
email = encode_email_address(email)
@@ -44,18 +52,13 @@
'Please enter a valid email address.'
)
- config = get_config()
- params = [('email', email), ('signature', sign(config, email))]
+ params = [('email', email), ('signature', sign(config, email)), ('product', product)]
lang = data.get('lang')
if lang:
params.append(('lang', lang))
- product = data.get('product', DEFAULT_PRODUCT)
- email_template = product + '_verification_email_template'
- params.append(('product', product))
-
sendMail(
- config.get('submit_email', email_template),
+ template,
{
'recipient': email,
'verification_url': '%s?%s' % (
@@ -76,6 +79,11 @@
config = get_config()
params = dict(parse_qsl(environ.get('QUERY_STRING', '')))
+ try:
+ filename = config.get('submit_email', params['product'] + '_filename')
+ except (KeyError, ConfigParser.NoOptionError):
+ return send_simple_response(start_response, 400, 'Unkown product')
Felix Dahlke 2015/09/08 13:44:21 s/Unkown/Unknown/?
Sebastian Noack 2015/09/08 14:09:43 Done.
+
email = params.get('email', '')
signature = params.get('signature', '')
if sign(config, email) != signature:
@@ -84,9 +92,6 @@
'Invalid signature in verification request.'
)
- product = params.get('product', DEFAULT_PRODUCT)
- filename = config.get('submit_email', product + '_filename')
-
with open(filename, 'ab', 0) as file:
fcntl.lockf(file, fcntl.LOCK_EX)
try:
« no previous file with comments | « sitescripts/submit_email/template/verification.mail ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld