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:
parent
74dd329440
commit
eed3517995
@ -272,7 +272,9 @@ func (c *Client) readThread(signalChan chan signalCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rawLines := buf[:ln]
|
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 {
|
for _, line := range lines {
|
||||||
if len(line) > 0 {
|
if len(line) > 0 {
|
||||||
c.server.eventChan <- Event{client: c, event: command, input: string(line)}
|
c.server.eventChan <- Event{client: c, event: command, input: string(line)}
|
||||||
|
Loading…
Reference in New Issue
Block a user