@setgroup:<string>=force will now do a "starts with" rather than an exact match

-> see FIRE-20266 - problem when group name contains a comma (or colon?)
  -> an exact match has precedence over a partial match; in case of multiple partial matches the last match wins (group ordering isn't guaranteed so essentially 'random')
  -> @setgroup:<uuid>=force is still preferred

--HG--
branch : RLVa
meow-7.2.2
Kitty Barnett 2016-11-12 13:45:02 +01:00
parent 51c503af99
commit 5266981c86
1 changed files with 19 additions and 7 deletions

View File

@ -2473,21 +2473,33 @@ template<> template<>
ERlvCmdRet RlvForceHandler<RLV_BHVR_SETGROUP>::onCommand(const RlvCommand& rlvCmd)
{
if (!RlvActions::canChangeActiveGroup(rlvCmd.getObjectID()))
{
return RLV_RET_FAILED_LOCK;
}
LLUUID idGroup; bool fValid = false;
if (idGroup.set(rlvCmd.getOption()))
if ("none" == rlvCmd.getOption())
{
idGroup.setNull();
fValid = true;
}
else if (idGroup.set(rlvCmd.getOption()))
{
fValid = (idGroup.isNull()) || (gAgent.isInGroup(idGroup, true));
}
else
{
for (S32 idxGroup = 0, cntGroup = gAgent.mGroups.size(); (idxGroup < cntGroup) && (idGroup.isNull()); idxGroup++)
if (boost::iequals(gAgent.mGroups.at(idxGroup).mName, rlvCmd.getOption()))
idGroup = gAgent.mGroups.at(idxGroup).mID;
fValid = (idGroup.notNull()) || ("none" == rlvCmd.getOption());
bool fExactMatch = false;
for (const auto& groupData : gAgent.mGroups)
{
// NOTE: exact matches take precedence over partial matches; in case of partial matches the last match wins
if (boost::istarts_with(groupData.mName, rlvCmd.getOption()))
{
idGroup = groupData.mID;
fExactMatch = groupData.mName.length() == rlvCmd.getOption().length();
if (fExactMatch)
break;
}
}
fValid = idGroup.notNull();
}
if (fValid)