Checking for single char line endings
authorSebastian Meyer <meyer@b1-systems.de>
Fri, 13 Jun 2014 12:52:55 +0000 (14:52 +0200)
committerDaniel Albers <daniel@lbe.rs>
Sat, 14 Jun 2014 19:41:17 +0000 (21:41 +0200)
This fixes problems with IRC servers sending only single char line
endings. Before the last char on each line for thos servers would be
chopped, now Quassel checks how the line ends and chops accordingly.
Fixes #1267

src/core/corenetwork.cpp

index b7d496a..80986f0 100644 (file)
@@ -411,7 +411,10 @@ void CoreNetwork::socketHasData()
 {
     while (socket.canReadLine()) {
         QByteArray s = socket.readLine();
 {
     while (socket.canReadLine()) {
         QByteArray s = socket.readLine();
-        s.chop(2);
+        if (s.endsWith("\r\n"))
+            s.chop(2);
+        else if (s.endsWith("\n"))
+            s.chop(1);
         NetworkDataEvent *event = new NetworkDataEvent(EventManager::NetworkIncoming, this, s);
 #if QT_VERSION >= 0x040700
         event->setTimestamp(QDateTime::currentDateTimeUtc());
         NetworkDataEvent *event = new NetworkDataEvent(EventManager::NetworkIncoming, this, s);
 #if QT_VERSION >= 0x040700
         event->setTimestamp(QDateTime::currentDateTimeUtc());