Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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, |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 @url_handler('/submitEmail') | 35 @url_handler('/submitEmail') |
36 @form_handler | 36 @form_handler |
37 def submit_email(environ, start_response, data): | 37 def submit_email(environ, start_response, data): |
38 config = get_config() | 38 config = get_config() |
39 | 39 |
40 try: | 40 try: |
41 product = data['product'] | 41 product = data['product'] |
42 template = config.get('submit_email', product + '_verification_email_templat e') | 42 template = config.get('submit_email', product + '_verification_email_templat e') |
43 except (KeyError, ConfigParser.NoOptionError): | 43 except (KeyError, ConfigParser.NoOptionError): |
44 return send_simple_response(start_response, 400, 'Unkown product') | 44 return send_simple_response(start_response, 400, 'Unknown product') |
Felix Dahlke
2015/09/08 13:44:21
s/Unkown/Unknown?
Sebastian Noack
2015/09/08 14:09:43
Done.
| |
45 | 45 |
46 email = data.get('email', '').strip() | 46 email = data.get('email', '').strip() |
47 try: | 47 try: |
48 email = encode_email_address(email) | 48 email = encode_email_address(email) |
49 except ValueError: | 49 except ValueError: |
50 return send_simple_response( | 50 return send_simple_response( |
51 start_response, 400, | 51 start_response, 400, |
52 'Please enter a valid email address.' | 52 'Please enter a valid email address.' |
53 ) | 53 ) |
54 | 54 |
(...skipping 20 matching lines...) Expand all Loading... | |
75 ) | 75 ) |
76 | 76 |
77 @url_handler(VERIFICATION_PATH) | 77 @url_handler(VERIFICATION_PATH) |
78 def verify_email(environ, start_response): | 78 def verify_email(environ, start_response): |
79 config = get_config() | 79 config = get_config() |
80 params = dict(parse_qsl(environ.get('QUERY_STRING', ''))) | 80 params = dict(parse_qsl(environ.get('QUERY_STRING', ''))) |
81 | 81 |
82 try: | 82 try: |
83 filename = config.get('submit_email', params['product'] + '_filename') | 83 filename = config.get('submit_email', params['product'] + '_filename') |
84 except (KeyError, ConfigParser.NoOptionError): | 84 except (KeyError, ConfigParser.NoOptionError): |
85 return send_simple_response(start_response, 400, 'Unkown product') | 85 return send_simple_response(start_response, 400, 'Unknown product') |
Felix Dahlke
2015/09/08 13:44:21
s/Unkown/Unknown/?
Sebastian Noack
2015/09/08 14:09:43
Done.
| |
86 | 86 |
87 email = params.get('email', '') | 87 email = params.get('email', '') |
88 signature = params.get('signature', '') | 88 signature = params.get('signature', '') |
89 if sign(config, email) != signature: | 89 if sign(config, email) != signature: |
90 return send_simple_response( | 90 return send_simple_response( |
91 start_response, 403, | 91 start_response, 403, |
92 'Invalid signature in verification request.' | 92 'Invalid signature in verification request.' |
93 ) | 93 ) |
94 | 94 |
95 with open(filename, 'ab', 0) as file: | 95 with open(filename, 'ab', 0) as file: |
96 fcntl.lockf(file, fcntl.LOCK_EX) | 96 fcntl.lockf(file, fcntl.LOCK_EX) |
97 try: | 97 try: |
98 print >>file, email | 98 print >>file, email |
99 finally: | 99 finally: |
100 fcntl.lockf(file, fcntl.LOCK_UN) | 100 fcntl.lockf(file, fcntl.LOCK_UN) |
101 | 101 |
102 location = config.get('submit_email', 'successful_verification_redirect_locati on') | 102 location = config.get('submit_email', 'successful_verification_redirect_locati on') |
103 location = location.format(lang=quote(params.get('lang') or 'en', '')) | 103 location = location.format(lang=quote(params.get('lang') or 'en', '')) |
104 start_response('303 See Other', [('Location', location)]) | 104 start_response('303 See Other', [('Location', location)]) |
105 return [] | 105 return [] |
LEFT | RIGHT |