Bug 1584822 - add try/catch around MimeTextDecoder() in convert8BitHeader(). r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Sun, 29 Sep 2019 19:16:54 +0200
changeset 35901 7c12a5f614ca046ba37d90f5cb787bb519b0daa8
parent 35900 927fc0c2381cfb961743d54772941810309428a3
child 35902 fb4daed5bea1130f3e73829e644c4b822d374aa9
push id37
push usermozilla@jorgk.com
push dateMon, 30 Sep 2019 09:47:32 +0000
treeherdercomm-esr68@fb4daed5bea1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs1584822
Bug 1584822 - add try/catch around MimeTextDecoder() in convert8BitHeader(). r=aceman a=jorgk
mailnews/mime/jsmime/jsmime.js
--- a/mailnews/mime/jsmime/jsmime.js
+++ b/mailnews/mime/jsmime/jsmime.js
@@ -682,18 +682,22 @@
         // otherwise, we want to replace with substitution chars.
         let hasFallback =
           fallbackCharset && !fallbackCharset.toLowerCase().startsWith("utf");
         let utf8Decoder = new MimeTextDecoder("utf-8", { fatal: hasFallback });
         try {
           headerValue = utf8Decoder.decode(typedarray);
         } catch (e) {
           // Failed, try the fallback
-          let decoder = new MimeTextDecoder(fallbackCharset, { fatal: false });
-          headerValue = decoder.decode(typedarray);
+          try {
+            let decoder = new MimeTextDecoder(fallbackCharset, {
+              fatal: false,
+            });
+            headerValue = decoder.decode(typedarray);
+          } catch (ex) {}
         }
       }
       return headerValue;
     }
 
     /**
      * Decodes all RFC 2047 encoded-words in the input string. The string does not
      * necessarily have to contain any such words. This is useful, for example, for