summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-05-12 22:01:27 +0100
committerGitHub <noreply@github.com>2020-05-12 17:01:27 -0400
commitba40263fdda53446c7cae6e41885ebdee8bb7b52 (patch)
tree04f26a02f1853149e70f8c39047b0dbd56ec3a5c
parentaa29f1c2b9150e45392c925e174af0471bf41b66 (diff)
downloadgitea-ba40263fdda53446c7cae6e41885ebdee8bb7b52.tar.gz
gitea-ba40263fdda53446c7cae6e41885ebdee8bb7b52.zip
Unfortunately go template if does not shortcut (#11392)
Go template's `{{if ...}}` does not shortcut its tests therefore it is possible to cause a NPE unless you separate ifs into two. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
-rw-r--r--templates/repo/commit_page.tmpl6
1 files changed, 4 insertions, 2 deletions
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl
index 2e57207460..372cc4fb93 100644
--- a/templates/repo/commit_page.tmpl
+++ b/templates/repo/commit_page.tmpl
@@ -104,8 +104,10 @@
{{else}}
<i class="unlock icon"></i>
{{.i18n.Tr .Verification.Reason}}
- {{if and .Verification.SigningKey (ne .Verification.SigningKey.KeyID "")}}
- <span class="pull-right"><span class="ui text">{{.i18n.Tr "repo.commits.gpg_key_id"}}:</span> <i class="warning icon"></i>{{.Verification.SigningKey.KeyID}}</span>
+ {{if .Verification.SigningKey}}
+ {{if ne .Verification.SigningKey.KeyID ""}}
+ <span class="pull-right"><span class="ui text">{{.i18n.Tr "repo.commits.gpg_key_id"}}:</span> <i class="warning icon"></i>{{.Verification.SigningKey.KeyID}}</span>
+ {{end}}
{{end}}
{{end}}
</div>