multilineedit: handle unterminated mIRC codes
[quassel.git] / src / uisupport / multilineedit.cpp
index 166e12c..a9a2ae2 100644 (file)
@@ -601,6 +601,10 @@ QString MultiLineEdit::convertMircCodesToHtml(const QString& text)
         }
 
         posRight = text.indexOf(mircCode.cap(), posRight + 1);
+        if (posRight == -1) {
+            words << text.mid(posLeft);
+            break;  // unclosed color code; can't process
+        }
         words << text.mid(posLeft, posRight + 1 - posLeft);
         posLeft = posRight + 1;
     }