From 193bb48048b073bf72491dcc3203574cf1898db5 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 20 Oct 2014 21:25:25 +0200 Subject: [PATCH] FIRE-10704: [RLVa] Don't filter parts of words out just because they match a name under restraint; fix provided under LGPL by Lirusaito Faers (Singularity viewer) --- 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 32060c260f..3fa5ad31cd 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -35,7 +35,8 @@ //#include "lscript_byteformat.h" #include "fsscriptlibrary.h" -#include +#include // icontains +#include // regex_replace_all #include // #include "lltrace.h" @@ -363,12 +364,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 @@ -391,16 +392,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); } } }