summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/templatetags/package_extras.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py
index 01bf7510..67c7fbbc 100644
--- a/packages/templatetags/package_extras.py
+++ b/packages/templatetags/package_extras.py
@@ -1,4 +1,4 @@
-from urllib import urlencode, quote as urlquote
+from urllib import urlencode, quote as urlquote, unquote
try:
from urlparse import parse_qs
except ImportError:
@@ -13,6 +13,17 @@ def link_encode(url, query, doseq=False):
data = urlencode(query, doseq).replace('&', '&')
return "%s?%s" % (url, data)
+@register.filter
+def url_unquote(original_url):
+ try:
+ url = original_url
+ if isinstance(url, unicode):
+ url = url.encode('ascii')
+ url = unquote(url).decode('utf-8')
+ return url
+ except UnicodeError:
+ return original_url
+
class BuildQueryStringNode(template.Node):
def __init__(self, sortfield):
self.sortfield = sortfield