From 8866ba3a7f6c463fe9bf56630a6677206824e603 Mon Sep 17 00:00:00 2001
From: Rider Linden <rider@lindenlab.com>
Date: Mon, 2 Nov 2015 12:34:59 -0800
Subject: [PATCH] MAINT-5812: Correctly pull a string from the raw body.  Only
 compare languages if detected_language is blank.

---
 indra/newview/lltranslate.cpp     | 9 ++++++---
 indra/newview/llviewermessage.cpp | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp
index 76fba82ef67..e2108d67a8f 100755
--- a/indra/newview/lltranslate.cpp
+++ b/indra/newview/lltranslate.cpp
@@ -192,11 +192,14 @@ void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::s
     LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
     LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
 
-    std::string translation, detected_lang, err_msg;
+    std::string translation, err_msg;
+    std::string detected_lang(fromTo.second);
 
     int parseResult = status.getType();
-    if (this->parseResponse(parseResult, result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asString(), 
-        translation, detected_lang, err_msg))
+    const LLSD::Binary &rawBody = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary();
+    std::string body(rawBody.cbegin(), rawBody.cend());
+
+    if (this->parseResponse(parseResult, body, translation, detected_lang, err_msg))
     {
         // Fix up the response
         LLStringUtil::replaceString(translation, "&lt;", "<");
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7000dcf21b5..d995ce4cdf9 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -3496,7 +3496,7 @@ void translateSuccess(LLChat chat, LLSD toastArgs, std::string originalMsg, std:
 {
     // filter out non-interesting responses  
     if (!translation.empty()
-        && (expectLang != detected_language)
+        && ((detected_language.empty()) || (expectLang != detected_language))
         && (LLStringUtil::compareInsensitive(translation, originalMsg) != 0))
     {
         chat.mText += " (" + translation + ")";
-- 
GitLab