From 0b3a4371c504c45c8a4504d114efb2ca674374e0 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Wed, 18 Jul 2012 13:34:08 +0200 Subject: m_namesx Handle colons in channel names properly Fixes #258 reported by @FxChiP --- src/modules/m_namesx.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 2603b0ce5..7e9c5fd48 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -83,13 +83,16 @@ class ModuleNamesX : public Module void OnSendWhoLine(User* source, const std::vector& params, User* user, std::string& line) { - if (!cap.ext.get(source) || line.empty()) + if (!cap.ext.get(source)) return; - std::string::size_type pos = line.find(':'); - if (pos == std::string::npos || pos < 2) + // Channel names can contain ":", and ":" as a 'start-of-token' delimiter is + // only ever valid after whitespace, so... find the actual delimiter first! + // Thanks to FxChiP for pointing this out. + std::string::size_type pos = line.find(" :"); + if (pos == std::string::npos || pos == 0) return; - pos -= 2; + pos--; // Don't do anything if the user has no prefixes if ((line[pos] == 'H') || (line[pos] == 'G') || (line[pos] == '*')) return; -- cgit v1.2.3