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]
This commit is contained in:
ed 2016-03-07 17:57:50 -05:00 committed by Harry Jeffery
parent 74dd329440
commit eed3517995

View File

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