From ba40263fdda53446c7cae6e41885ebdee8bb7b52 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 12 May 2020 22:01:27 +0100 Subject: [PATCH] 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 Co-authored-by: techknowlogick --- templates/repo/commit_page.tmpl | 6 ++++-- 1 file 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}} {{.i18n.Tr .Verification.Reason}} - {{if and .Verification.SigningKey (ne .Verification.SigningKey.KeyID "")}} - {{.i18n.Tr "repo.commits.gpg_key_id"}}: {{.Verification.SigningKey.KeyID}} + {{if .Verification.SigningKey}} + {{if ne .Verification.SigningKey.KeyID ""}} + {{.i18n.Tr "repo.commits.gpg_key_id"}}: {{.Verification.SigningKey.KeyID}} + {{end}} {{end}} {{end}}