From ac24c9a656bb713dc29b86f54ca74dc435d1a16b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 29 2015 08:59:21 +0000 Subject: Rely on urllib and aiohttp.MultiDict to do the url arguments parsing This gives us a much more robust url argument parsing and corresponds to what's in the doc: http://aiohttp.readthedocs.org/en/stable/server.html#handling-get-params --- diff --git a/mdapi/__init__.py b/mdapi/__init__.py index 89965d9..4b9b07f 100644 --- a/mdapi/__init__.py +++ b/mdapi/__init__.py @@ -23,6 +23,7 @@ Top level of the mdapi aiohttp application. ''' import os +import urllib try: import simplejson as json @@ -31,7 +32,7 @@ except ImportError: import asyncio import werkzeug -from aiohttp import web +from aiohttp import web, MultiDict import mdapi.lib as mdapilib import mdapi.file_lock as file_lock @@ -95,8 +96,8 @@ def _get_pkg(branch, name): def _get_pretty(request): pretty = False - query_string = request.query_string.lower() - if query_string in ['pretty=1', 'pretty=true']: + get_params = MultiDict(urllib.parse.parse_qsl(request.query_string.lower())) + if str(get_params.get('pretty', None)) in ['1', 'true']: pretty = True # Assume pretty if html is requested and pretty is not disabled elif 'text/html' in request.headers.get('ACCEPT', ''):