From 6c2871402dd8a9839cd3ad78594dc6a484815e03 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Sun, 19 Oct 2014 21:44:45 -0400 Subject: [PATCH] [RLVa] Don't filter parts of words out just because they match a name under restraint This fix is free to be reused under LGPL.. --- indra/newview/rlvcommon.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index e736193ef..491a1e3d4 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -36,7 +36,8 @@ #include "rlvlocks.h" #include "../lscript/lscript_byteformat.h" //Need LSCRIPTRunTimePermissionBits and SCRIPT_PERMISSION_* -#include +#include // icontains +#include // regex_replace_all // ============================================================================ // RlvNotifications @@ -373,12 +374,12 @@ void RlvUtil::filterLocation(std::string& strUTF8Text) LLWorld::region_list_t regions = LLWorld::getInstance()->getRegionList(); const std::string& strHiddenRegion = RlvStrings::getString(RLV_STRING_HIDDEN_REGION); for (LLWorld::region_list_t::const_iterator itRegion = regions.begin(); itRegion != regions.end(); ++itRegion) - boost::ireplace_all(strUTF8Text, (*itRegion)->getName(), strHiddenRegion); + boost::replace_all_regex(strUTF8Text, boost::regex("\\b" + (*itRegion)->getName() + "\\b", boost::regex::icase), strHiddenRegion); // Filter any mention of the parcel name LLViewerParcelMgr* pParcelMgr = LLViewerParcelMgr::getInstance(); if (pParcelMgr) - boost::ireplace_all(strUTF8Text, pParcelMgr->getAgentParcelName(), RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL)); + boost::replace_all_regex(strUTF8Text, boost::regex("\\b" + pParcelMgr->getAgentParcelName() + "\\b", boost::regex::icase), RlvStrings::getString(RLV_STRING_HIDDEN_PARCEL)); } // Checked: 2010-12-08 (RLVa-1.2.2c) | Modified: RLVa-1.2.2c @@ -401,16 +402,16 @@ void RlvUtil::filterNames(std::string& strUTF8Text, bool fFilterLegacy) if (boost::icontains(strLegacyName, strDisplayName)) { if (fFilterLegacy) - boost::ireplace_all(strUTF8Text, strLegacyName, strAnonym); + boost::replace_all_regex(strUTF8Text, boost::regex("\\b" + strLegacyName + "\\b", boost::regex::icase), strAnonym); if (fFilterDisplay) - boost::ireplace_all(strUTF8Text, strDisplayName, strAnonym); + boost::replace_all_regex(strUTF8Text, boost::regex("\\b" + strDisplayName + "\\b", boost::regex::icase), strAnonym); } else { if (fFilterDisplay) - boost::ireplace_all(strUTF8Text, strDisplayName, strAnonym); + boost::replace_all_regex(strUTF8Text, boost::regex("\\b" + strDisplayName + "\\b", boost::regex::icase), strAnonym); if (fFilterLegacy) - boost::ireplace_all(strUTF8Text, strLegacyName, strAnonym); + boost::replace_all_regex(strUTF8Text, boost::regex("\\b" + strLegacyName + "\\b", boost::regex::icase), strAnonym); } } }