From 1c08c20a5a1156852dbd3184360bf3ea40378916 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 2 May 2005 01:41:04 +0000 Subject: Fix for bug #62 (replaces only occur once per line) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1278 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_censor.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index c3e52899a..2d81b98f6 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -94,7 +94,7 @@ class ModuleCensor : public Module { if ((pattern != "") && (text != "")) { - while (strstr(text.c_str(),pattern.c_str())) + while (text.find(pattern) != std::string::npos) { int pos = text.find(pattern); text.erase(pos,pattern.length()); @@ -111,7 +111,7 @@ class ModuleCensor : public Module for (int index = 0; index < MyConf->Enumerate("badword"); index++) { std::string pattern = MyConf->ReadValue("badword","text",index); - if (strstr(text.c_str(),pattern.c_str())) + if (text.find(pattern) != std::string::npos) { std::string replace = MyConf->ReadValue("badword","replace",index); @@ -130,8 +130,6 @@ class ModuleCensor : public Module { this->ReplaceLine(text,pattern,replace); } - - return 0; } } return 0; @@ -143,7 +141,7 @@ class ModuleCensor : public Module for (int index = 0; index < MyConf->Enumerate("badword"); index++) { std::string pattern = MyConf->ReadValue("badword","text",index); - if (strstr(text.c_str(),pattern.c_str())) + if (text.find(pattern) != std::string::npos) { std::string replace = MyConf->ReadValue("badword","replace",index); @@ -162,8 +160,6 @@ class ModuleCensor : public Module { this->ReplaceLine(text,pattern,replace); } - - return 0; } } return 0; -- cgit v1.2.3