From eed3517995b6ccf5219920c177ab83c8426da7bb Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 7 Mar 2016 17:57:50 -0500 Subject: [PATCH] Normalized newlines so that \r and \n also work as message terminators [messages are supposed to end in \r\n per RFC 1459, but some clients (Mibbit) sometimes use \r or \n rather than \r\n] --- client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 0fe5c42..025afde 100644 --- a/client.go +++ b/client.go @@ -272,7 +272,9 @@ func (c *Client) readThread(signalChan chan signalCode) { } rawLines := buf[:ln] - lines := bytes.Split(rawLines, []byte("\r\n")) + rawLines = bytes.Replace(rawLines, []byte("\r\n"), []byte("\n"), -1) + rawLines = bytes.Replace(rawLines, []byte("\r"), []byte("\n"), -1) + lines := bytes.Split(rawLines, []byte("\n")) for _, line := range lines { if len(line) > 0 { c.server.eventChan <- Event{client: c, event: command, input: string(line)}