From 064f0216b420ba4cd8503473c036139a68f5a392 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Thu, 23 Aug 2012 18:55:57 -0400 Subject: [PATCH] Disable Newline AntiSpam when AntiSpam is not enabled. --- indra/newview/llviewermessage.cpp | 62 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 182955f99..a48ac85d7 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1946,23 +1946,26 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, name); msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message); // NaCl - Newline flood protection - LLViewerObject* obj=gObjectList.findObject(from_id); - if(!from_id.isNull() //Not from nothing. - && gAgent.getID() != from_id //Not from self. - && !(obj && obj->permYouOwner())) //Not from own object. - { - static LLCachedControl SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines"); - boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES); - if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines) + static LLCachedControl AntiSpamEnabled(gSavedSettings,"AntiSpamEnabled",false); + if(AntiSpamEnabled){ + LLViewerObject* obj=gObjectList.findObject(from_id); + if(!from_id.isNull() //Not from nothing. + && gAgent.getID() != from_id //Not from self. + && !(obj && obj->permYouOwner())) //Not from own object. { - NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id); - if(gSavedSettings.getBOOL("AntiSpamNotify")) + static LLCachedControl SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines"); + boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES); + if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines) { - LLSD args; - args["MESSAGE"] = "Message: Blocked newline flood from "+from_id.asString(); - LLNotificationsUtil::add("SystemMessageTip", args); + NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id); + if(gSavedSettings.getBOOL("AntiSpamNotify")) + { + LLSD args; + args["MESSAGE"] = "Message: Blocked newline flood from "+from_id.asString(); + LLNotificationsUtil::add("SystemMessageTip", args); + } + return; } - return; } } // NaCl End @@ -3519,23 +3522,26 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg); // NaCl - Newline flood protection - LLViewerObject* obj=gObjectList.findObject(from_id); - if(!(from_id.isNull()) //Not from nothing. - || !(gAgent.getID() != from_id) //Not from self. - || !(obj && obj->permYouOwner())) //Not from own object. - { - static LLCachedControl SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines"); - boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES); - if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines) + static LLCachedControl AntiSpamEnabled(gSavedSettings,"AntiSpamEnabled",false); + if(AntiSpamEnabled){ + LLViewerObject* obj=gObjectList.findObject(from_id); + if(!(from_id.isNull()) //Not from nothing. + || !(gAgent.getID() != from_id) //Not from self. + || !(obj && obj->permYouOwner())) //Not from own object. { - NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id); - if(gSavedSettings.getBOOL("AntiSpamNotify")) + static LLCachedControl SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines"); + boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES); + if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines) { - LLSD args; - args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString(); - LLNotificationsUtil::add("SystemMessageTip", args); + NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id); + if(gSavedSettings.getBOOL("AntiSpamNotify")) + { + LLSD args; + args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString(); + LLNotificationsUtil::add("SystemMessageTip", args); + } + return; } - return; } } // NaCl End