diff --git a/indra/newview/NACLantispam.cpp b/indra/newview/NACLantispam.cpp index a46378268..44d91cc13 100644 --- a/indra/newview/NACLantispam.cpp +++ b/indra/newview/NACLantispam.cpp @@ -23,6 +23,14 @@ #include #include +bool can_block(const LLUUID& id) +{ + if (id.isNull() || gAgent.getID() == id) return false; //Can't block system or self. + if (const LLViewerObject* obj = gObjectList.findObject(id)) //From an object, + return !obj->permYouOwner(); //not own object. + return true; +} + U32 NACLAntiSpamRegistry::globalAmount; U32 NACLAntiSpamRegistry::globalTime; bool NACLAntiSpamRegistry::bGlobalQueue; @@ -308,10 +316,8 @@ void NACLAntiSpamRegistry::blockGlobalEntry(LLUUID& source) bool NACLAntiSpamRegistry::checkQueue(U32 name, LLUUID& source, U32 multiplier) //returns true if blocked { - if(source.isNull() || gAgent.getID() == source) return false; - LLViewerObject *obj=gObjectList.findObject(source); - if(obj && obj->permYouOwner()) return false; - + if (!can_block(source)) return false; + int result; if(bGlobalQueue) { diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 9a7c114f5..2743215bf 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -85,7 +85,6 @@ #include "aicurl.h" #include "aihttptimeoutpolicy.h" -#include "NACLantispam.h" // for NaCl Antispam Registry #ifdef TOGGLE_HACKED_GODLIKE_VIEWER BOOL gHackGodmode = FALSE; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index c66a706d8..e158ab6e6 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -182,6 +182,7 @@ // NaCl - Antispam Registry #include "NACLantispam.h" +bool can_block(const LLUUID& id); // NaCl - Newline flood protection #include static const boost::regex NEWLINES("\\n{1}"); @@ -1956,27 +1957,22 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message); // NaCl - Newline flood protection 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. + if (AntiSpamEnabled && can_block(from_id)) + { + 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 SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines"); - boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES); - if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines) + NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id); + llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl; + if(gSavedSettings.getBOOL("AntiSpamNotify")) { - NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id); - llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl; - if(gSavedSettings.getBOOL("AntiSpamNotify")) - { - LLSD args; - args["SOURCE"] = from_id.asString(); - args["AMOUNT"] = boost::lexical_cast(SpamNewlines); - LLNotificationsUtil::add("AntiSpamNewlineFlood", args); - } - return; + LLSD args; + args["SOURCE"] = from_id.asString(); + args["AMOUNT"] = boost::lexical_cast(SpamNewlines); + LLNotificationsUtil::add("AntiSpamNewlineFlood", args); } + return; } } // NaCl End @@ -3540,25 +3536,20 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) // NaCl - Newline flood protection 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. + if (AntiSpamEnabled && can_block(from_id)) + { + 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 SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines"); - boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES); - if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines) + NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id); + if(gSavedSettings.getBOOL("AntiSpamNotify")) { - 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; + LLSD args; + args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString(); + LLNotificationsUtil::add("SystemMessageTip", args); } + return; } } // NaCl End