From: Shane Synan Date: Sat, 1 Sep 2018 21:17:33 +0000 (-0500) Subject: common: Fix whitespace CTCP ignore invalid index X-Git-Tag: 0.13-rc2~57 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6fd69e84e6c395a108e6b2620c6428907b7d7efd common: Fix whitespace CTCP ignore invalid index When constructing a CTCP ignore, check that splitting on whitespace results in non-empty list before taking from the list. If it's empty, fall back to assuming any valid sender, i.e. "*"/".*" depending on whether the rule is set as wildcard or regex. This fixes issues when receiving a CTCP with an invalid CTCP ignore rule such as " ". --- diff --git a/src/common/ignorelistmanager.h b/src/common/ignorelistmanager.h index 7bf4bab3..baf3cc10 100644 --- a/src/common/ignorelistmanager.h +++ b/src/common/ignorelistmanager.h @@ -122,10 +122,27 @@ public: // This is not performance-intensive; sticking with QRegExp for Qt 4 is fine // Split based on whitespace characters QStringList split(contents().split(QRegExp("\\s+"), QString::SkipEmptyParts)); - // Match on the first item - _cacheCtcpSender = split.takeFirst(); - // Track the rest as CTCP types to ignore - _cacheCtcpTypes = split; + // Match on the first item, handling empty rules/matches + if (!split.isEmpty()) { + // Take the first item as the sender + _cacheCtcpSender = split.takeFirst(); + // Track the rest as CTCP types to ignore + _cacheCtcpTypes = split; + } + else { + // No match found - this can happen if a pure whitespace CTCP ignore rule is + // created. Fall back to matching all senders. + if (_isRegEx) { + // RegEx match everything + _cacheCtcpSender = ".*"; + } + else { + // Wildcard match everything + _cacheCtcpSender = "*"; + } + // Clear the types (split is already empty) + _cacheCtcpTypes = split; + } } _type = type; }