Bug 1356245 - implement fallback when content type can't be determined. r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Sun, 16 Apr 2017 22:37:49 +0200
changeset 24470 78171c3a96f2
parent 24469 d8949acb05a3
child 24471 9d19a9b732a0
push id2059
push usermozilla@jorgk.com
push dateMon, 17 Apr 2017 06:53:03 +0000
treeherdercomm-aurora@9d19a9b732a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1356245
Bug 1356245 - implement fallback when content type can't be determined. r=mkmelin a=jorgk
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -5691,19 +5691,24 @@ function loadBlockedImage(aURL, aReturnD
   else {
     let fnMatch = /[?&;]filename=([^?&]+)/.exec(aURL);
     filename = (fnMatch && fnMatch[1]) || "";
   }
   filename = decodeURIComponent(filename);
   let uri = Services.io.newURI(aURL);
   let contentType;
   if (filename) {
-    contentType = Components.classes["@mozilla.org/mime;1"]
-      .getService(Components.interfaces.nsIMIMEService)
-      .getTypeFromURI(uri);
+    try {
+      contentType = Components.classes["@mozilla.org/mime;1"]
+        .getService(Components.interfaces.nsIMIMEService)
+        .getTypeFromURI(uri);
+    } catch (ex) {
+      contentType = "image/png";
+    }
+
     if (!contentType.startsWith("image/")) {
       // Unsafe to unblock this. It would just be garbage either way.
       throw new Error("Won't unblock; URL=" + aURL +
                       ", contentType=" + contentType);
     }
   }
   else {
     // Assuming image/png is the best we can do.