Skip to content

Commit

Permalink
Merge pull request #9228 from ronie/stringcompare
Browse files Browse the repository at this point in the history
fix stringcompare against 'true' or 'false'
  • Loading branch information
ronie committed Mar 2, 2016
2 parents f327e14 + 5cfe6b7 commit 0adf7b1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions xbmc/GUIInfoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,21 +968,25 @@ int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool
const Property &cat = info[0];
if (info.size() == 1)
{ // single category
if (cat.name == "false" || cat.name == "no" || cat.name == "off")
if (cat.name == "false" || cat.name == "no")
return SYSTEM_ALWAYS_FALSE;
else if (cat.name == "true" || cat.name == "yes" || cat.name == "on")
else if (cat.name == "true" || cat.name == "yes")
return SYSTEM_ALWAYS_TRUE;
if (cat.name == "isempty" && cat.num_params() == 1)
return AddMultiInfo(GUIInfo(STRING_IS_EMPTY, TranslateSingleString(cat.param(), listItemDependent)));
else if (cat.name == "stringcompare" && cat.num_params() == 2)
{
int info = TranslateSingleString(cat.param(0), listItemDependent);
int info2 = TranslateSingleString(cat.param(1), listItemDependent);
if (info2 > 0)
return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
// pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
std::string label = CGUIInfoLabel::GetLabel(cat.param(1));
StringUtils::ToLower(label);
// 'true', 'false', 'yes', 'no' are valid strings, do not resolve them to SYSTEM_ALWAYS_TRUE or SYSTEM_ALWAYS_FALSE
if (label != "true" && label != "false" && label != "yes" && label != "no")
{
int info2 = TranslateSingleString(cat.param(1), listItemDependent);
if (info2 > 0)
return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
}
int compareString = ConditionalStringParameter(label);
return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString));
}
Expand Down

0 comments on commit 0adf7b1

Please sign in to comment.