mirror of https://github.com/fluffle/goirc
check bad tag inputs
This commit is contained in:
parent
e670ca970c
commit
32ae1211bb
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue