]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fixed matching
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 9 Apr 2005 13:33:57 +0000 (13:33 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 9 Apr 2005 13:33:57 +0000 (13:33 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1022 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_filter.cpp
src/wildcard.cpp

index 569ed06379d60270212d48392bbfdf6fdf0ec3f2..054d779639c2778aca7ba3ff00caa88ddc76aeb1 100644 (file)
@@ -26,8 +26,6 @@
 
 /* $ModDesc: An enhanced version of the unreal m_filter.so used by chatspike.net */
 
-        
-
 class ModuleFilter : public Module
 {
  Server *Srv;
@@ -65,11 +63,11 @@ class ModuleFilter : public Module
        
        virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
        {
-               std::string text2 = text + " ";
+               std::string text2 = text+" ";
                for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
                {
                        std::string pattern = MyConf->ReadValue("keyword","pattern",index);
-                       if (Srv->MatchText(text2,pattern))
+                       if ((Srv->MatchText(text2,pattern)) || (Srv->MatchText(text,pattern)))
                        {
                                std::string target = "";
                                std::string reason = MyConf->ReadValue("keyword","reason",index);
@@ -114,11 +112,11 @@ class ModuleFilter : public Module
        
        virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
        {
-               std::string text2 = text + " ";
+               std::string text2 = text+" ";
                for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
                {
                        std::string pattern = MyConf->ReadValue("keyword","pattern",index);
-                       if (Srv->MatchText(text2,pattern))
+                       if ((Srv->MatchText(text2,pattern)) || (Srv->MatchText(text,pattern)))
                        {
                                std::string target = "";
                                std::string reason = MyConf->ReadValue("keyword","reason",index);
index 8b4190539f9fb7a8287b7c0596e92cb0c9bd1bf7..47fbaf0024db42902082b2f9373a11956c2533e7 100644 (file)
@@ -101,6 +101,17 @@ bool match(const char* literal, const char* mask)
        strlcpy(M,mask,10240);
        strlower(L);
        strlower(M);
+       // short circuit literals
+       log(DEBUG,"Match '%s' to '%s'",L,M);
+       if ((!strchr(M,'*')) && (!strchr(M,'?')))
+       {
+               log(DEBUG,"Short circuiting literal");
+               if (!strcasecmp(L,M))
+               {
+                       log(DEBUG,"Literal match");
+                       return true;
+               }
+       }
        match2(L,M);
        return (MWC == 2);
 }