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

Unified Diff: sitescripts/reports/web/updateReport.py

Issue 5717434384252928: Issue 2267 - Unify form handling by reusing form_handler() and encode_email_address() (Closed)
Patch Set: Addressed comment Created April 28, 2015, 8:42 a.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/formmail/web/formmail.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/reports/web/updateReport.py
===================================================================
--- a/sitescripts/reports/web/updateReport.py
+++ b/sitescripts/reports/web/updateReport.py
@@ -16,28 +16,13 @@
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
import re, os, sys, random
-from urlparse import parse_qsl
-from sitescripts.utils import get_config, get_template, setupStderr
-from sitescripts.web import url_handler
+from sitescripts.utils import get_config, get_template
+from sitescripts.web import url_handler, form_handler
from sitescripts.reports.utils import calculateReportSecret, calculateReportSecret_compat, getReport, saveReport, sendUpdateNotification, getUserId, updateUserUsefulness
@url_handler('/updateReport')
-def handleRequest(environ, start_response):
- setupStderr(environ['wsgi.errors'])
-
- if environ['REQUEST_METHOD'].upper() != 'POST' or not environ.get('CONTENT_TYPE', '').startswith('application/x-www-form-urlencoded'):
- return showError('Unsupported request method', start_response)
-
- try:
- request_body_length = int(environ['CONTENT_LENGTH'])
- except:
- return showError('Invalid or missing Content-Length header', start_response)
-
- request_body = environ['wsgi.input'].read(request_body_length)
- params = {}
- for key, value in parse_qsl(request_body):
- params[key] = value.decode('utf-8')
-
+@form_handler
+def handleRequest(environ, start_response, params):
guid = params.get('guid', '').lower()
if not re.match(r'^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$', guid):
return showError('Invalid or missing report GUID', start_response)
« no previous file with comments | « sitescripts/formmail/web/formmail.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld