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-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 secret = calculateReportSecret(guid) | 52 secret = calculateReportSecret(guid) |
53 if params.get('secret', '') != secret and params.get('secret', '') != calcul
ateReportSecret_compat(guid): | 53 if params.get('secret', '') != secret and params.get('secret', '') != calcul
ateReportSecret_compat(guid): |
54 return showError('Wrong secret value', start_response) | 54 return showError('Wrong secret value', start_response) |
55 | 55 |
56 reportData['status'] = params.get('status', '') | 56 reportData['status'] = params.get('status', '') |
57 if len(reportData['status']) > 1024: | 57 if len(reportData['status']) > 1024: |
58 reportData['status'] = reportData['status'][:1024] | 58 reportData['status'] = reportData['status'][:1024] |
59 | 59 |
60 oldusefulness = reportData.get('usefulness', '0') | 60 oldusefulness = reportData.get('usefulness', '0') |
61 reportData['usefulness'] = params.get('usefulness', '0') | 61 reportData['usefulness'] = params.get('usefulness', '0') |
62 if ('email' in reportData): | 62 if 'email' in reportData: |
63 updateUserUsefulness(getUserId(reportData['email']), reportData['usefuln
ess'], oldusefulness) | 63 updateUserUsefulness(getUserId(reportData['email']), reportData['usefuln
ess'], oldusefulness) |
64 | 64 |
65 saveReport(guid, reportData) | 65 saveReport(guid, reportData) |
66 | 66 |
67 if params.get('notify', '') and 'email' in reportData: | 67 if params.get('notify', '') and 'email' in reportData: |
68 email = reportData['email'] | 68 email = reportData['email'] |
69 email = re.sub(r' at ', r'@', email) | 69 email = re.sub(r' at ', r'@', email) |
70 email = re.sub(r' dot ', r'.', email) | 70 email = re.sub(r' dot ', r'.', email) |
71 if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email): | 71 if re.match(r'^[\w.%+-]+@[\w.%+-]+(\.[\w.%+-]+)+', email): |
72 sendUpdateNotification({ | 72 sendUpdateNotification({ |
73 'email': email, | 73 'email': email, |
74 'url': get_config().get('reports', 'urlRoot') + guid, | 74 'url': get_config().get('reports', 'urlRoot') + guid, |
75 'status': reportData['status'], | 75 'status': reportData['status'], |
76 }) | 76 }) |
77 | 77 |
78 newURL = get_config().get('reports', 'urlRoot') + guid | 78 newURL = get_config().get('reports', 'urlRoot') + guid |
79 newURL += '?updated=' + str(int(random.uniform(0, 10000))) | 79 newURL += '?updated=' + str(int(random.uniform(0, 10000))) |
80 newURL += '#secret=' + secret | 80 newURL += '#secret=' + secret |
81 start_response('302 Found', [('Location', newURL.encode('utf-8'))]) | 81 start_response('302 Found', [('Location', newURL.encode('utf-8'))]) |
82 return [] | 82 return [] |
83 | 83 |
84 | 84 |
85 def showError(message, start_response): | 85 def showError(message, start_response): |
86 template = get_template(get_config().get('reports', 'errorTemplate')) | 86 template = get_template(get_config().get('reports', 'errorTemplate')) |
87 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+
xml; charset=utf-8')]) | 87 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+
xml; charset=utf-8')]) |
88 return [template.render({'message': message}).encode('utf-8')] | 88 return [template.render({'message': message}).encode('utf-8')] |
OLD | NEW |