From 2a59dfbd472d14a26b40f8be6b2dcb8218c7ec9c Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sat, 29 Mar 2025 22:32:28 +0100 Subject: enable staticcheck QFxxxx rules (#34064) --- services/gitdiff/highlightdiff.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'services/gitdiff/highlightdiff.go') diff --git a/services/gitdiff/highlightdiff.go b/services/gitdiff/highlightdiff.go index 6e18651d83..e8be063e69 100644 --- a/services/gitdiff/highlightdiff.go +++ b/services/gitdiff/highlightdiff.go @@ -14,13 +14,14 @@ import ( // token is a html tag or entity, eg: "", "", "<" func extractHTMLToken(s string) (before, token, after string, valid bool) { for pos1 := 0; pos1 < len(s); pos1++ { - if s[pos1] == '<' { + switch s[pos1] { + case '<': pos2 := strings.IndexByte(s[pos1:], '>') if pos2 == -1 { return "", "", s, false } return s[:pos1], s[pos1 : pos1+pos2+1], s[pos1+pos2+1:], true - } else if s[pos1] == '&' { + case '&': pos2 := strings.IndexByte(s[pos1:], ';') if pos2 == -1 { return "", "", s, false -- cgit v1.2.3