diff --git a/browser/components/places/src/nsPlacesImportExportService.cpp b/browser/components/places/src/nsPlacesImportExportService.cpp index ec818fffcbce..666a487605bb 100644 --- a/browser/components/places/src/nsPlacesImportExportService.cpp +++ b/browser/components/places/src/nsPlacesImportExportService.cpp @@ -2038,17 +2038,19 @@ nsPlacesImportExportService::WriteLivemark(nsINavHistoryResultNode* aFolder, con nsCOMPtr feedURI; rv = mLivemarkService->GetFeedURI(folderId, getter_AddRefs(feedURI)); NS_ENSURE_SUCCESS(rv, rv); - nsCString feedSpec; - rv = feedURI->GetSpec(feedSpec); - NS_ENSURE_SUCCESS(rv, rv); + if (feedURI) { + nsCString feedSpec; + rv = feedURI->GetSpec(feedSpec); + NS_ENSURE_SUCCESS(rv, rv); - // write feed URI - rv = aOutput->Write(kFeedURIAttribute, sizeof(kFeedURIAttribute)-1, &dummy); - NS_ENSURE_SUCCESS(rv, rv); - rv = WriteEscapedUrl(feedSpec, aOutput); - NS_ENSURE_SUCCESS(rv, rv); - rv = aOutput->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy); - NS_ENSURE_SUCCESS(rv, rv); + // write feed URI + rv = aOutput->Write(kFeedURIAttribute, sizeof(kFeedURIAttribute)-1, &dummy); + NS_ENSURE_SUCCESS(rv, rv); + rv = WriteEscapedUrl(feedSpec, aOutput); + NS_ENSURE_SUCCESS(rv, rv); + rv = aOutput->Write(kQuoteStr, sizeof(kQuoteStr)-1, &dummy); + NS_ENSURE_SUCCESS(rv, rv); + } // get the optional site URI nsCOMPtr siteURI; diff --git a/toolkit/components/places/src/nsLivemarkService.js b/toolkit/components/places/src/nsLivemarkService.js index cffd4fe996fc..f889cc95d282 100644 --- a/toolkit/components/places/src/nsLivemarkService.js +++ b/toolkit/components/places/src/nsLivemarkService.js @@ -301,17 +301,21 @@ LivemarkService.prototype = { * startup. */ getSiteURI: function LS_getSiteURI(container) { - this._ensureLivemark(container); - var siteURIString; - try { - siteURIString = + try { + this._ensureLivemark(container); + + // getItemAnnotationString() can throw if there is no annotation + var siteURIString = this._ans.getItemAnnotationString(container, LMANNO_SITEURI); + + return gIoService.newURI(siteURIString, null, null); } catch (ex) { - return null; + // temporary logging, for bug #381894 + LOG("getSiteURI failed: " + ex); + LOG("siteURIString: " + siteURIString); } - - return gIoService.newURI(siteURIString, null, null); + return null; }, setSiteURI: function LS_setSiteURI(container, siteURI) { @@ -327,9 +331,19 @@ LivemarkService.prototype = { }, getFeedURI: function LS_getFeedURI(container) { - return gIoService.newURI(this._ans.getItemAnnotationString(container, - LMANNO_FEEDURI), - null, null); + try { + // getItemAnnotationString() can throw if there is no annotation + var feedURIString = this._ans.getItemAnnotationString(container, + LMANNO_FEEDURI); + + return gIoService.newURI(feedURIString, null, null); + } + catch (ex) { + // temporary logging, for bug #381894 + LOG("getFeedURI failed: " + ex); + LOG("feedURIString: " + feedURIString); + } + return null; }, setFeedURI: function LS_setFeedURI(container, feedURI) {