Skip to content

Commit

Permalink
Fix link to ChangeLog on security page for WeeChat versions ≥ 4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Sep 9, 2024
1 parent 412aab6 commit 8a58aa9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion weechat/doc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

from weechat.common.i18n import i18n_autogen
from weechat.common.models import Project
from weechat.common.tracker import commits_links, tracker_links
from weechat.common.tracker import (
commits_links,
tracker_links,
repo_link_release,
)
from weechat.common.utils import version_to_list


URL_CVE = {
Expand Down Expand Up @@ -281,6 +286,17 @@ def mitigation_i18n(self):
return mark_safe(gettext(self.mitigation.replace('\r\n', '\n')))
return ''

def link_changelog(self):
"""Return the link to the ChangeLog for the fixed version."""
if not self.fixed:
return '#'
if version_to_list(self.fixed) >= [4, 4]:
# version ≥ 4.4.0: link to release on GitHub
return repo_link_release(self.project.name, self.fixed)
# version < 4.4.0: link to ChangeLog-x.y.z.html
filename = f'ChangeLog-{self.fixed}.html'
return f'/files/doc/{self.project.name}/{filename}'

class Meta:
ordering = ['-date']

Expand Down
2 changes: 1 addition & 1 deletion weechat/templates/doc/security.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ <h5>{% trans "Vulnerability" %}</h5>
</span>
({{ security.release_date|localdate }})
-
<a href="/files/doc/{{ project }}/ChangeLog-{{ security.fixed }}.html">
<a href="{{ security.link_changelog }}">
{% trans "ChangeLog" %}
</a>
{% else %}
Expand Down

0 comments on commit 8a58aa9

Please sign in to comment.