Panic if isHighlight is called with empty nick

Let's make sure callers never do this. We'd go into an infinite
loop previously.
This commit is contained in:
Simon Ser 2023-04-16 21:22:08 +02:00
parent 0548fdfa09
commit e5bce700a9

4
irc.go
View file

@ -228,6 +228,10 @@ func isWordBoundary(r rune) bool {
} }
func isHighlight(text, nick string) bool { func isHighlight(text, nick string) bool {
if len(nick) == 0 {
panic("isHighlight called with empty nick")
}
for { for {
i := strings.Index(text, nick) i := strings.Index(text, nick)
if i < 0 { if i < 0 {