Bug 1555471 - add try/catch around MimeTextDecoder() in MimeParser._startBody(). r=aceman
authorJorg K <jorgk@jorgk.com>
Sun, 29 Sep 2019 23:13:55 +0200
changeset 37016 bba4379257e401bcb8d1fff07cb66f88b23eee4d
parent 37015 1d6ea04f0f4424074752400b08bc4bf2adab70df
child 37017 1b282633191defb0a9411d6cfe8e059aa2b87e45
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersaceman
bugs1555471
Bug 1555471 - add try/catch around MimeTextDecoder() in MimeParser._startBody(). r=aceman
mailnews/mime/jsmime/jsmime.js
--- a/mailnews/mime/jsmime/jsmime.js
+++ b/mailnews/mime/jsmime/jsmime.js
@@ -2649,19 +2649,23 @@
       // Set up the encoder for charset conversions; only do this for text parts.
       // Other parts are almost certainly binary, so no translation should be
       // applied to them.
       if (
         this._options.strformat == "unicode" &&
         contentType.mediatype == "text"
       ) {
         // If the charset is nonempty, initialize the decoder
+        this._decoder = null;
         if (this._charset !== "") {
-          this._decoder = new MimeTextDecoder(this._charset);
-        } else {
+          try {
+            this._decoder = new MimeTextDecoder(this._charset);
+          } catch (e) {}
+        }
+        if (!this._decoder) {
           // There's no charset we can use for decoding, so pass through as an
           // identity encoder or otherwise this._coerceData will complain.
           this._decoder = {
             decode(buffer) {
               return MimeParser.prototype._coerceData(
                 buffer,
                 "binarystring",
                 true