src: Yearly copyright bump
[quassel.git] / src / common / ignorelistmanager.h
index 7bf4bab..c22a2f2 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2019 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -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;
         }