summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-04-20 13:32:09 -0500
committerDan McGee <dan@archlinux.org>2013-04-20 13:32:09 -0500
commitbb18fa3323a0494a2774ea61911572b089d04b6d (patch)
treee97498b26ec50cb9c9448380ffb215e3dc8fb69f /packages
parent7873cb9a052c7991f3d91ddf4dc05caef6305cd7 (diff)
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: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r--packages/templatetags/package_extras.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index ef0e1aea..f7392a96 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -37,6 +37,12 @@ class BuildQueryStringNode(template.Node):
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:]]