summaryrefslogtreecommitdiffstats
path: root/packages/templatetags
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-02-12 21:54:05 -0600
committerDan McGee <dan@archlinux.org>2012-02-12 21:54:05 -0600
commit30acd5c81689545ba02dfa392b118f262f3511b8 (patch)
tree393d3b50680a9d997df7d0ecbf20d24fe83997d8 /packages/templatetags
parentc3ebf7deae0bb04f1637e9a52e7f9f38d454fec7 (diff)
downloadarchweb-30acd5c81689545ba02dfa392b118f262f3511b8.tar.gz
archweb-30acd5c81689545ba02dfa392b118f262f3511b8.zip
Protect urlencode calls against Unicode data
These would cause page errors if passed anything not in the ASCII character set. This change allows for packages to have names composed of any Unicode characters, not just those in the ASCII set. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/templatetags')
-rw-r--r--packages/templatetags/package_extras.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 25e943ff..5cc826ed 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -9,8 +9,11 @@ from django.utils.html import escape
register = template.Library()
-def link_encode(url, query, doseq=False):
- data = urlencode(query, doseq).replace('&', '&amp;')
+def link_encode(url, query):
+ # massage the data into all utf-8 encoded strings first, so urlencode
+ # doesn't barf at the data we pass it
+ query = dict((k, unicode(v).encode('utf-8')) for k, v in query.items())
+ data = urlencode(query).replace('&', '&amp;')
return "%s?%s" % (url, data)
@register.filter