diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-19 18:32:17 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-19 18:32:17 -0500 |
commit | c9c3dffdec1afa8ce4ff8d26113ff871a25d224d (patch) | |
tree | 4eabb057db832de3f803d13a9d4be599e08daac0 | |
parent | 1908b3c4609d1c3acf04c94a490516ff5284d2c7 (diff) |
Ensure ampersands are properly escaped in hrefs
This was pointed out by the W3C validator.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | packages/templatetags/package_extras.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py index e4c7a010..42001aa5 100644 --- a/packages/templatetags/package_extras.py +++ b/packages/templatetags/package_extras.py @@ -9,6 +9,10 @@ from django.utils.html import escape register = template.Library() +def link_encode(url, query, doseq=False): + data = urlencode(query, doseq).replace('&', '&') + return "%s?%s" % (url, data) + class BuildQueryStringNode(template.Node): def __init__(self, sortfield): self.sortfield = sortfield @@ -22,7 +26,7 @@ class BuildQueryStringNode(template.Node): qs['sort'] = ['-' + self.sortfield] else: qs['sort'] = [self.sortfield] - return urlencode(qs, True) + return urlencode(qs, True).replace('&', '&') @register.tag(name='buildsortqs') def do_buildsortqs(parser, token): @@ -74,27 +78,29 @@ def svn_trunk(package): @register.simple_tag def get_wiki_link(package): + url = "https://wiki.archlinux.org/index.php/Special:Search" data = { 'search': package.pkgname, } - return "https://wiki.archlinux.org/index.php/Special:Search?%s" % \ - urlencode(data) + return link_encode(url, data) @register.simple_tag def bugs_list(package): + url = "https://bugs.archlinux.org/" data = { 'project': package.repo.bugs_project, 'string': package.pkgname, } - return "https://bugs.archlinux.org/?%s" % urlencode(data) + return link_encode(url, data) @register.simple_tag def bug_report(package): + url = "https://bugs.archlinux.org/newtask" data = { 'project': package.repo.bugs_project, 'product_category': package.repo.bugs_category, 'item_summary': '[%s]' % package.pkgname, } - return "https://bugs.archlinux.org/newtask?%s" % urlencode(data) + return link_encode(url, data) # vim: set ts=4 sw=4 et: |