Commit bb18fa33 authored by Dan McGee's avatar Dan McGee
Browse files

Fix parsing issues when query string keys contain unicode



This is dirty, but it works. There is probably a better and cleaner way
to do all of this, but for now just fix it quickly.
Signed-off-by: default avatarDan McGee <dan@archlinux.org>
parent 7873cb9a
......@@ -37,6 +37,12 @@ def __init__(self, sortfield):
def render(self, context):
qs = parse_qs(context['current_query'])
# This is really dirty. The crazy round trips we do on our query string
# mean we get things like u'\xe2\x98\x83' in our views, when we should
# have simply u'\u2603' or a byte string of the UTF-8 value. Force the
# keys and list of values to be byte strings only.
qs = {k.encode('latin-1'): [v.encode('latin-1') for v in vals]
for k, vals in qs.items()}
if 'sort' in qs and self.sortfield in qs['sort']:
if self.sortfield.startswith('-'):
qs['sort'] = [self.sortfield[1:]]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment