diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-10-08 02:16:29 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-10-08 02:16:29 +0000 |
commit | 6cb718568469e6138ecd0d40c6218da6d0359f0a (patch) | |
tree | 5295e9c1d73e5d1797525e0912636751efadebfd | |
parent | a01056dd830d604548292cefc4835e51534a29a7 (diff) |
* EXT-1282 Fixed a crash when attempting to display strings with [] in them
(merged from viewer-2.0-qa-4)
-rw-r--r-- | indra/llcommon/llstring.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 6516d1779e..f2edd5c559 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1018,7 +1018,11 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) bool found_replacement = false; std::string replacement; - if (tokens.size() == 1) + if (tokens.size() == 0) + { + found_replacement = false; + } + else if (tokens.size() == 1) { found_replacement = simpleReplacement (replacement, tokens[0], substitutions); } @@ -1054,9 +1058,9 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) } else { - // we had no replacement, so leave the string we searched for so that it gets noticed by QA - // "hello [NAME_NOT_FOUND]" is output - output += std::string("[") + tokens[0] + std::string("]"); + // we had no replacement, use the string as is + // e.g. "hello [MISSING_REPLACEMENT]" or "-=[Stylized Name]=-" + output += std::string(s, key_start, start-key_start); } tokens.clear(); } @@ -1092,7 +1096,11 @@ S32 LLStringUtil::format(std::string& s, const LLSD& substitutions) bool found_replacement = false; std::string replacement; - if (tokens.size() == 1) + if (tokens.size() == 0) + { + found_replacement = false; + } + else if (tokens.size() == 1) { found_replacement = simpleReplacement (replacement, tokens[0], substitutions); } @@ -1120,9 +1128,9 @@ S32 LLStringUtil::format(std::string& s, const LLSD& substitutions) } else { - // we had no replacement, so leave the string we searched for so that it gets noticed by QA - // "hello [NAME_NOT_FOUND]" is output - output += std::string("[") + tokens[0] + std::string("]"); + // we had no replacement, use the string as is + // e.g. "hello [MISSING_REPLACEMENT]" or "-=[Stylized Name]=-" + output += std::string(s, key_start, start-key_start); } tokens.clear(); } |