OLD | NEW |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 writer = DictWriter(new_formlog, fieldnames=params.keys()) | 93 writer = DictWriter(new_formlog, fieldnames=params.keys()) |
94 writer.writeheader() | 94 writer.writeheader() |
95 writer.writerow(params) | 95 writer.writerow(params) |
96 return | 96 return |
97 | 97 |
98 | 98 |
99 def validate_fields(fields, params): | 99 def validate_fields(fields, params): |
100 errors = [] | 100 errors = [] |
101 for field, spec in fields.items(): | 101 for field, spec in fields.items(): |
102 if 'mandatory' in spec.value and field not in params: | 102 if 'mandatory' in spec.value and field not in params: |
103 errors.append(make_error(spec, 'mandatory', | 103 errors.append(make_error(spec, 'mandatory', |
104 'No {} entered'.format(field))) | 104 'No {} entered'.format(field))) |
105 if 'email' in spec.value and field in params: | 105 if 'email' in spec.value and field in params: |
106 try: | 106 try: |
107 params[field] = encode_email_address(params[field]) | 107 params[field] = encode_email_address(params[field]) |
108 except ValueError: | 108 except ValueError: |
109 errors.append(make_error(spec, 'email', 'Invalid email')) | 109 errors.append(make_error(spec, 'email', 'Invalid email')) |
110 | 110 |
111 unexpected_fields = ' '.join(set(params.keys()) - set(fields.keys())) | 111 unexpected_fields = ' '.join(set(params.keys()) - set(fields.keys())) |
112 if unexpected_fields: | 112 if unexpected_fields: |
113 errors.append('Unexpected field/fields: ' + str(unexpected_fields)) | 113 errors.append('Unexpected field/fields: ' + str(unexpected_fields)) |
114 return errors | 114 return errors |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 start_response('200 OK', response_headers) | 162 start_response('200 OK', response_headers) |
163 return '' | 163 return '' |
164 | 164 |
165 return url, handler | 165 return url, handler |
166 | 166 |
167 | 167 |
168 conf_dict = conf_parse(get_config_items()) | 168 conf_dict = conf_parse(get_config_items()) |
169 for name, config in conf_dict.items(): | 169 for name, config in conf_dict.items(): |
170 url, handler = make_handler(name, config) | 170 url, handler = make_handler(name, config) |
171 registerUrlHandler(url, handler) | 171 registerUrlHandler(url, handler) |
OLD | NEW |