Skip to content

Commit ba40263

Browse files
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 <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent aa29f1c commit ba40263

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

templates/repo/commit_page.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@
104104
{{else}}
105105
<i class="unlock icon"></i>
106106
{{.i18n.Tr .Verification.Reason}}
107-
{{if and .Verification.SigningKey (ne .Verification.SigningKey.KeyID "")}}
108-
<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>
107+
{{if .Verification.SigningKey}}
108+
{{if ne .Verification.SigningKey.KeyID ""}}
109+
<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>
110+
{{end}}
109111
{{end}}
110112
{{end}}
111113
</div>

0 commit comments

Comments
 (0)