Changelog table crashes if it tries to render a commit with an empty message
Mads Kiilerich
mads at kiilerich.com
Mon Dec 14 22:15:35 UTC 2020
Ouch, yeah, .splitlines() is confusingly different from .split('\n') .
Thanks for the patch.
Would it perhaps be better to just use .split instead of .splitlines()?
But since the commit message text is shown as a link, would it perhaps
be even better to avoid the void and show a text like "(No commit message)"?
And if it is possible to have an empty commit message, should we perhaps
also have nice handling of the case where the first line is empty?
So something like
--- kallithea/templates/changelog/changelog_table.html
+++ kallithea/templates/changelog/changelog_table.html
@@ -55,7 +55,7 @@
<td class="date">
<div data-toggle="tooltip"
title="${h.fmt_date(cs.date)}">${h.age(cs.date,True)}</div>
</td>
- <% message_lines = cs.message.splitlines() %>
+ <% message_lines = cs.message.strip().splitlines() or [_("(No
commit message)")] %>
%if len(message_lines) > 1:
<td class="expand_commit" title="${_('Expand commit message')}">
<i class="icon-align-left"></i>
Also, I can see we also have the same problem in pullrequest_show.html ...
/Mads
On 12/14/20 10:04 PM, Brett Smith wrote:
>
> Hi,
>
> I recently upgraded a Kallithea server to 0.6.3, and I was running
> into an issue where trying to view the landing page for one specific
> repository, but not others, was crashing.
>
> I tracked this down to the changelog_table.html template. It runs
> message_lines = cs.message.splitlines() and tries to show the first
> line of the message by rendering message_lines[0]. However, if the
> commit message is completely empty, message_lines will be too, so
> trying to access message_lines[0] raises an uncaught IndexError.
>
> Attached is a patch that does the bare minimum to avoid the crash, by
> forcing message_lines to contain an empty string in this case. It
> might be nice to do something nicer like render a dedicated, localized
> message in this case. But hopefully this helps identify the issue.
>
> Hope this helps. If you need any additional information, please let me
> know.
>
> Thanks,
>
> --
> Brett Smith
>
> _______________________________________________
> kallithea-general mailing list
> kallithea-general at sfconservancy.org
> https://lists.sfconservancy.org/mailman/listinfo/kallithea-general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20201214/1d4de5c9/attachment.html>
More information about the kallithea-general
mailing list