Deal with empty ISUPPORT param names

This commit is contained in:
Ken-Håvard Lieng 2018-04-29 02:13:22 +02:00
parent f2504cc245
commit 62e115498f
2 changed files with 12 additions and 8 deletions

View File

@ -58,9 +58,9 @@ func NewClient(nick, username string) *Client {
func (c *Client) GetNick() string { func (c *Client) GetNick() string {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() nick := c.nick
c.lock.Unlock()
return c.nick return nick
} }
func (c *Client) setNick(nick string) { func (c *Client) setNick(nick string) {
@ -71,9 +71,9 @@ func (c *Client) setNick(nick string) {
func (c *Client) Connected() bool { func (c *Client) Connected() bool {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() connected := c.connected
c.lock.Unlock()
return c.connected return connected
} }
func (c *Client) Nick(nick string) { func (c *Client) Nick(nick string) {

View File

@ -81,9 +81,13 @@ func newISupport() *iSupport {
} }
func (i *iSupport) parse(params []string) { func (i *iSupport) parse(params []string) {
i.lock.Lock()
for _, param := range params[1 : len(params)-1] { for _, param := range params[1 : len(params)-1] {
parts := strings.SplitN(param, "=", 2) parts := strings.SplitN(param, "=", 2)
i.lock.Lock() if parts[0] == "" {
continue
}
if parts[0][0] == '-' { if parts[0][0] == '-' {
delete(i.support, parts[0][1:]) delete(i.support, parts[0][1:])
} else if len(parts) == 2 { } else if len(parts) == 2 {
@ -91,8 +95,8 @@ func (i *iSupport) parse(params []string) {
} else { } else {
i.support[param] = "" i.support[param] = ""
} }
i.lock.Unlock()
} }
i.lock.Unlock()
} }
func (i *iSupport) Has(key string) bool { func (i *iSupport) Has(key string) bool {