diff --git a/client/line.go b/client/line.go index 64e090c..1f523d0 100644 --- a/client/line.go +++ b/client/line.go @@ -119,11 +119,17 @@ func ParseLine(s string) *Line { // all tags are escaped, so splitting on ; is right by design for _, tag := range strings.Split(rawTags, ";") { + if tag == "" { + return nil + } + pair := strings.Split(tagsReplacer.Replace(tag), "=") - if len(pair) > 1 { + if len(pair) < 2 { + line.Tags[tag] = "" + } else if len(pair) == 2 { line.Tags[pair[0]] = pair[1] } else { - line.Tags[tag] = "" + return nil } } } diff --git a/client/line_test.go b/client/line_test.go index ba2c090..b041639 100644 --- a/client/line_test.go +++ b/client/line_test.go @@ -137,6 +137,8 @@ func TestLineTags(t *testing.T) { Args: []string{"me", "Hello"}, }, }, + {"@a=a; :nick!ident@host.com PRIVMSG me :Hello", nil}, // Bad inputs + {"@a=a=a :nick!ident@host.com PRIVMSG me :Hello", nil}, } for i, test := range tests {