Bug 1014672 - & character translated to & r=mikedeboer
authorFelipe Gomes <felipc@gmail.com>
Thu, 05 Jun 2014 14:52:40 -0300
changeset 206086 a010a557a1b59f0b576c094eac2f3cca70237c69
parent 206085 b0dbdb35eacef702d9ee3759ee9b724f6cea62fb
child 206087 aa1371a67ba15617ab96f1e65c5558b398f21ebe
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1014672
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1014672 - & character translated to &amp; r=mikedeboer
browser/components/translation/BingTranslator.jsm
--- a/browser/components/translation/BingTranslator.jsm
+++ b/browser/components/translation/BingTranslator.jsm
@@ -151,19 +151,26 @@ this.BingTranslation.prototype = {
       // of items (from the number of items submitted), we can't use this chunk
       // because all items would be paired incorrectly.
       return false;
     }
 
     let error = false;
     for (let i = 0; i < len; i++) {
       try {
-        bingRequest.translationData[i][0].parseResult(
-          results[i].firstChild.nodeValue
-        );
+        let result = results[i].firstChild.nodeValue;
+        let root = bingRequest.translationData[i][0];
+
+        if (root.isSimpleRoot) {
+          // Workaround for Bing's service problem in which "&" chars in
+          // plain-text TranslationItems are double-escaped.
+          result = result.replace("&amp;", "&", "g");
+        }
+
+        root.parseResult(result);
       } catch (e) { error = true; }
     }
 
     return !error;
   },
 
   /**
    * This function will determine what is the data to be used for