From: A. Wilcox Date: Mon, 3 Jun 2019 05:16:30 +0000 (-0500) Subject: multilineedit: handle unterminated mIRC codes X-Git-Tag: test-travis-01~10 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=b359cfe9fdd2427993dc0b2f3f605fd69bbe6bd2 multilineedit: handle unterminated mIRC codes Currently, if an unterminated mIRC code is pasted into Quassel, trying to go through input line history will cause a deadlock. This breaks the loop at the cost of possibly mangling the formatting of the line somewhat. This is seen as more acceptable than locking up, and the line is invalid anyway. Reproducer: ```sh printf '\00303,08HONK' | xclip -selection clipboard ``` Paste into Quassel, send, press Up arrow key. Bug originally found by @sroracle, reported to Adélie Linux, patched by yours truly. --- diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index 166e12cc..a9a2ae24 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -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; }