summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/templatetags/package_extras.py13
-rw-r--r--templates/packages/details.html2
2 files changed, 13 insertions, 2 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
diff --git a/templates/packages/details.html b/templates/packages/details.html
index 2998592f..a9908012 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -108,7 +108,7 @@
</tr><tr>
<th>Upstream URL:</th>
<td>{% if pkg.url %}<a href="{{ pkg.url }}"
- title="Visit the website for {{ pkg.pkgname }}">{{ pkg.url }}</a>{% endif %}</td>
+ title="Visit the website for {{ pkg.pkgname }}">{{ pkg.url|url_unquote }}</a>{% endif %}</td>
</tr><tr>
<th>License(s):</th>
<td>{{ pkg.licenses.all|join:", " }}</td>