Task: Corrected str_replace calls

This commit is contained in:
Paul Beckingham
2016-12-11 16:09:37 -05:00
parent f0988b52d0
commit 98278eff2a

View File

@@ -1643,12 +1643,8 @@ void Task::validate_before (const std::string& left, const std::string& right)
// ] -> &close; // ] -> &close;
const std::string Task::encode (const std::string& value) const const std::string Task::encode (const std::string& value) const
{ {
std::string modified = value; auto modified = str_replace (value, "[", "&open;");
return str_replace (modified, "]", "&close;");
str_replace (modified, "[", "&open;");
str_replace (modified, "]", "&close;");
return modified;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -1661,18 +1657,11 @@ const std::string Task::encode (const std::string& value) const
// : <- &colon; // : <- &colon;
const std::string Task::decode (const std::string& value) const const std::string Task::decode (const std::string& value) const
{ {
if (value.find ('&') != std::string::npos) if (value.find ('&') == std::string::npos)
{ return value;
std::string modified = value;
// Supported encodings. auto modified = str_replace (value, "&open;", "[");
str_replace (modified, "&open;", "["); return str_replace (modified, "&close;", "]");
str_replace (modified, "&close;", "]");
return modified;
}
return value;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////