check bad tag inputs

This commit is contained in:
Jake Bailey 2016-01-11 16:43:19 -06:00
parent e670ca970c
commit 32ae1211bb
2 changed files with 10 additions and 2 deletions

View File

@ -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
}
}
}

View File

@ -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 {