Verified Commit 16718689 authored by Kevin Morris's avatar Kevin Morris
Browse files

fix: links to cgit should be url encoded

Closes #283



Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 708ade4d
......@@ -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))
......
......@@ -6,21 +6,21 @@
<h4>{{ "Package Actions" | tr }}</h4>
<ul class="small">
<li>
<a href="/cgit/aur.git/tree/PKGBUILD?h={{ pkgbase.Name }}">
<a href="{{ config.get('options', 'source_file_uri') | format("PKGBUILD", pkgbase.Name | quote_plus) }}">
{{ "View PKGBUILD" | tr }}
</a>
/
<a href="/cgit/aur.git/log/?h={{ pkgbase.Name }}">
<a href="{{ config.get('options', 'log_uri') | format(pkgbase.Name | quote_plus) }}">
{{ "View Changes" | tr }}
</a>
</li>
<li>
<a href="/cgit/aur.git/snapshot/{{ pkgbase.Name }}.tar.gz">
<a href="{{ config.get('options', 'snapshot_uri') | format(pkgbase.Name | quote_plus) }}">
{{ "Download snapshot" | tr }}
</a>
</li>
<li>
<a href="https://wiki.archlinux.org/title/Special:Search?search={{ pkgbase.Name }}">
<a href="https://wiki.archlinux.org/title/Special:Search?{{ { 'search': pkgbase.Name } | urlencode }}">
{{ "Search wiki" | tr }}
</a>
</li>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment