diff options
author | Peter Powell <petpow@saberuk.com> | 2012-09-12 16:27:59 +0100 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-10-19 17:50:08 +0200 |
commit | 3479532178c73ae47da4729865e5bfc91a299027 (patch) | |
tree | b696e2420e8b7fdefb78fdd9ae62559d0be43c1b /src/helperfuncs.cpp | |
parent | aa1f46885810c4779ae539c142fdee15b556206b (diff) |
Fix for #268.
- Move color stripping code to helperfuncs.
- Strip color codes before matching filters.
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r-- | src/helperfuncs.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index a6df520c5..3efa58bba 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -196,6 +196,33 @@ bool InspIRCd::IsValidMask(const std::string &mask) return true; } +void InspIRCd::StripColor(std::string &sentence) +{ + /* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */ + int seq = 0; + + for (std::string::iterator i = sentence.begin(); i != sentence.end();) + { + if (*i == 3) + seq = 1; + else if (seq && (( ((*i >= '0') && (*i <= '9')) || (*i == ',') ) )) + { + seq++; + if ( (seq <= 4) && (*i == ',') ) + seq = 1; + else if (seq > 3) + seq = 0; + } + else + seq = 0; + + if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31))) + i = sentence.erase(i); + else + ++i; + } +} + /* true for valid channel name, false else */ bool IsChannelHandler::Call(const char *chname, size_t max) { |