From 167186895625f57e8fb88713b34d3a989307f8ee Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sun, 13 Feb 2022 17:34:33 -0800 Subject: [PATCH] fix: links to cgit should be url encoded Closes #283 Signed-off-by: Kevin Morris --- aurweb/scripts/rendercomment.py | 8 ++++++-- templates/partials/packages/actions.html | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/aurweb/scripts/rendercomment.py b/aurweb/scripts/rendercomment.py index 2af5384e..87f8b89f 100755 --- a/aurweb/scripts/rendercomment.py +++ b/aurweb/scripts/rendercomment.py @@ -2,6 +2,7 @@ import sys +from urllib.parse import quote_plus from xml.etree.ElementTree import Element import bleach @@ -72,13 +73,16 @@ class GitCommitsInlineProcessor(markdown.inlinepatterns.InlineProcessor): def handleMatch(self, m, data): oid = m.group(1) if oid not in self._repo: - # Unkwown OID; preserve the orginal text. + # Unknown OID; preserve the orginal text. return (None, None, None) el = Element('a') commit_uri = aurweb.config.get("options", "commit_uri") prefixlen = util.git_search(self._repo, oid) - el.set('href', commit_uri % (self._head, oid[:prefixlen])) + el.set('href', commit_uri % ( + quote_plus(self._head), + quote_plus(oid[:prefixlen]) + )) el.text = markdown.util.AtomicString(oid[:prefixlen]) return (el, m.start(0), m.end(0)) diff --git a/templates/partials/packages/actions.html b/templates/partials/packages/actions.html index 8d024506..88420222 100644 --- a/templates/partials/packages/actions.html +++ b/templates/partials/packages/actions.html @@ -6,21 +6,21 @@

{{ "Package Actions" | tr }}