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

Delta Between Two Patch Sets: sitescripts/submit_email/web/submit_email.py

Issue 5177883412660224: Issue 2234 - Add a WSGI controller to collect email addresses for the Adblock Browser iOS launch (Closed)
Left Patch Set: Addressed comments Created April 27, 2015, 1:37 p.m.
Right Patch Set: URL-encode language before inserting into URL Created April 28, 2015, 10:50 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/submit_email/web/__init__.py ('k') | sitescripts/utils.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import fcntl 18 import fcntl
19 import hmac 19 import hmac
20 import hashlib 20 import hashlib
21 import wsgiref.util 21 import wsgiref.util
22 from urlparse import parse_qsl, urljoin 22 from urlparse import parse_qsl, urljoin
23 from urllib import urlencode 23 from urllib import urlencode, quote
24 24
25 from sitescripts.utils import get_config, sendMail, encode_email_address 25 from sitescripts.utils import get_config, sendMail, encode_email_address
26 from sitescripts.web import url_handler, form_handler, send_simple_response 26 from sitescripts.web import url_handler, form_handler, send_simple_response
27 27
28 VERIFICATION_PATH = '/verifyEmail' 28 VERIFICATION_PATH = '/verifyEmail'
29 29
30 def sign(config, data): 30 def sign(config, data):
31 secret = config.get('submit_email', 'secret') 31 secret = config.get('submit_email', 'secret')
32 return hmac.new(secret, data, hashlib.sha1).hexdigest() 32 return hmac.new(secret, data, hashlib.sha1).hexdigest()
33 33
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 filename = config.get('submit_email', 'filename') 82 filename = config.get('submit_email', 'filename')
83 with open(filename, 'ab', 0) as file: 83 with open(filename, 'ab', 0) as file:
84 fcntl.lockf(file, fcntl.LOCK_EX) 84 fcntl.lockf(file, fcntl.LOCK_EX)
85 try: 85 try:
86 print >>file, email 86 print >>file, email
87 finally: 87 finally:
88 fcntl.lockf(file, fcntl.LOCK_UN) 88 fcntl.lockf(file, fcntl.LOCK_UN)
89 89
90 location = config.get('submit_email', 'successful_verification_redirect_locati on') 90 location = config.get('submit_email', 'successful_verification_redirect_locati on')
91 location = location.format(lang=params.get('lang', 'en')) 91 location = location.format(lang=quote(params.get('lang') or 'en', ''))
kzar 2015/04/28 11:13:42 Looks like a typo at the end there? ", ''"
Sebastian Noack 2015/04/28 11:31:25 The empty string at the end is the second argument
kzar 2015/04/28 11:33:41 Oh I see.
Sebastian Noack 2015/04/28 11:36:04 I meant (forward) slashes.
92 start_response('303 See Other', [('Location', location)]) 92 start_response('303 See Other', [('Location', location)])
93 return [] 93 return []
LEFTRIGHT

Powered by Google App Engine
This is Rietveld