diff options
author | TheFox0x7 <thefox0x7@gmail.com> | 2025-03-29 22:32:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-29 17:32:28 -0400 |
commit | 2a59dfbd472d14a26b40f8be6b2dcb8218c7ec9c (patch) | |
tree | 9d55ad3ee2d7564eeb52691c1700a1ecec4a8609 /services/gitdiff | |
parent | 5564c39105ba38ab74371d04f8b214afc6229cca (diff) | |
download | gitea-2a59dfbd472d14a26b40f8be6b2dcb8218c7ec9c.tar.gz gitea-2a59dfbd472d14a26b40f8be6b2dcb8218c7ec9c.zip |
enable staticcheck QFxxxx rules (#34064)
Diffstat (limited to 'services/gitdiff')
-rw-r--r-- | services/gitdiff/highlightdiff.go | 5 |
1 files changed, 3 insertions, 2 deletions
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: "<span ...>", "</span>", "<" 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 |