Bug 1049234 - deal with broken settings in feedwriter instead of dying completely, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 28 Aug 2014 11:41:21 +0100
changeset 202184 b48dd68342d7f35cd14fa6e9dbc92ce554c0bad6
parent 202126 141dc6c20917c7fcd027d6c44df09a1058880525
child 202185 ee64990e130c73e37c8dfc2ee1f498af7299f490
push idunknown
push userunknown
push dateunknown
reviewersjaws
bugs1049234
milestone34.0a1
Bug 1049234 - deal with broken settings in feedwriter instead of dying completely, r=jaws
browser/components/feeds/FeedWriter.js
--- a/browser/components/feeds/FeedWriter.js
+++ b/browser/components/feeds/FeedWriter.js
@@ -884,17 +884,23 @@ FeedWriter.prototype = {
     try {
       handler = prefs.getCharPref(getPrefReaderForType(feedType));
     }
     catch (ex) { }
 
     switch (handler) {
       case "web": {
         if (this._handlersMenuList) {
-          var url = prefs.getComplexValue(getPrefWebForType(feedType), Ci.nsISupportsString).data;
+          var url;
+          try {
+            url = prefs.getComplexValue(getPrefWebForType(feedType), Ci.nsISupportsString).data;
+          } catch (ex) {
+            LOG("FeedWriter._setSelectedHandler: invalid or no handler in prefs");
+            return;
+          }
           var handlers =
             this._handlersMenuList.getElementsByAttribute("webhandlerurl", url);
           if (handlers.length == 0) {
             LOG("FeedWriter._setSelectedHandler: selected web handler isn't in the menulist")
             return;
           }
 
           this._safeDoCommand(handlers[0]);
@@ -1034,16 +1040,20 @@ FeedWriter.prototype = {
     Cu.evalInSandbox(codeStr, this._contentSandbox);
 
     // List of web handlers
     var wccr = Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
                getService(Ci.nsIWebContentConverterService);
     var handlers = wccr.getContentHandlers(this._getMimeTypeForFeedType(feedType));
     if (handlers.length != 0) {
       for (var i = 0; i < handlers.length; ++i) {
+        if (!handlers[i].uri) {
+          LOG("Handler with name " + handlers[i].name + " has no URI!? Skipping...");
+          continue;
+        }
         menuItem = liveBookmarksMenuItem.cloneNode(false);
         menuItem.removeAttribute("selected");
         menuItem.className = "menuitem-iconic";
         menuItem.setAttribute("label", handlers[i].name);
         menuItem.setAttribute("handlerType", "web");
         menuItem.setAttribute("webhandlerurl", handlers[i].uri);
         this._contentSandbox.menuItem = menuItem;
         codeStr = "handlersMenuPopup.appendChild(menuItem);";