From 32ae1211bb8662cabdeb277edae5d3706a7a18a3 Mon Sep 17 00:00:00 2001 From: Jake Bailey Date: Mon, 11 Jan 2016 16:43:19 -0600 Subject: [PATCH] check bad tag inputs --- client/line.go | 10 ++++++++-- client/line_test.go | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) 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 {