From 2cc838ec2237e11eaa30d0521d34233e8d1701c3 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 22 May 2004 21:45:59 +0000 Subject: Fixed issue where ReplaceText threw an exception (!) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@823 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/censor.conf.example | 2 +- src/modules/m_censor.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/censor.conf.example b/docs/censor.conf.example index ff6136e1d..296fb22d0 100644 --- a/docs/censor.conf.example +++ b/docs/censor.conf.example @@ -8,5 +8,5 @@ # replace="text to replace with"> - + diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 40e4ee92b..769e6e493 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -71,11 +71,14 @@ class ModuleCensor : public Module virtual void ReplaceLine(std::string &text,std::string pattern, std::string replace) { - while (strstr(text.c_str(),pattern.c_str())) + if ((pattern != "") && (text != "")) { - int pos = text.find(pattern); - text.erase(pos,pattern.length()); - text.insert(pos,replace); + while (strstr(text.c_str(),pattern.c_str())) + { + int pos = text.find(pattern); + text.erase(pos,pattern.length()); + text.insert(pos,replace); + } } } -- cgit v1.2.3