diff --git a/browser/components/places/content/bookmarkProperties.js b/browser/components/places/content/bookmarkProperties.js index 029931147ec..3e2ddb3b302 100755 --- a/browser/components/places/content/bookmarkProperties.js +++ b/browser/components/places/content/bookmarkProperties.js @@ -715,7 +715,7 @@ var BookmarkPropertiesPanel = { try { var value = this._element(aTextboxID).value; if (value) { - var uri = PlacesUtils._uri(value); + var uri = PlacesUtils.createFixedURI(value); return true; } } catch (e) { } @@ -822,7 +822,7 @@ var BookmarkPropertiesPanel = { if (this._itemType == BOOKMARK_ITEM) { // location - var url = PlacesUtils._uri(this._element("editURLBar").value); + var url = PlacesUtils.createFixedURI(this._element("editURLBar").value); if (!this._bookmarkURI.equals(url)) transactions.push(PlacesUtils.ptm.editBookmarkURI(itemId, url)); @@ -858,7 +858,7 @@ var BookmarkPropertiesPanel = { } else if (this._itemType == LIVEMARK_CONTAINER) { var feedURIString = this._element("feedLocationTextfield").value; - var feedURI = PlacesUtils._uri(feedURIString); + var feedURI = PlacesUtils.createFixedURI(feedURIString); if (!this._feedURI.equals(feedURI)) { transactions.push( PlacesUtils.ptm.editLivemarkFeedURI(this._folderId, feedURI)); @@ -868,7 +868,7 @@ var BookmarkPropertiesPanel = { var newSiteURIString = this._element("feedSiteLocationTextfield").value; var newSiteURI = null; if (newSiteURIString) - newSiteURI = PlacesUtils._uri(newSiteURIString); + newSiteURI = PlacesUtils.createFixedURI(newSiteURIString); if ((!newSiteURI && this._siteURI) || (newSiteURI && (!this._siteURI || !this._siteURI.equals(newSiteURI)))) { @@ -912,7 +912,7 @@ var BookmarkPropertiesPanel = { */ _getCreateNewBookmarkTransaction: function BPP__getCreateNewBookmarkTransaction(aContainer, aIndex) { - var uri = PlacesUtils._uri(this._element("editURLBar").value); + var uri = PlacesUtils.createFixedURI(this._element("editURLBar").value); var title = this._element("userEnteredName").label; var keyword = this._element("keywordTextfield").value; var annotations = []; @@ -984,12 +984,12 @@ var BookmarkPropertiesPanel = { _getCreateNewLivemarkTransaction: function BPP__getCreateNewLivemarkTransaction(aContainer, aIndex) { var feedURIString = this._element("feedLocationTextfield").value; - var feedURI = PlacesUtils._uri(feedURIString); + var feedURI = PlacesUtils.createFixedURI(feedURIString); var siteURIString = this._element("feedSiteLocationTextfield").value; var siteURI = null; if (siteURIString) - siteURI = PlacesUtils._uri(siteURIString); + siteURI = PlacesUtils.createFixedURI(siteURIString); var name = this._element("namePicker").value; return PlacesUtils.ptm.createLivemark(feedURI, siteURI, name, diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index fcbaff41c22..1efc47915a7 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -500,10 +500,9 @@ var gEditItemOverlay = { }, onLocationFieldBlur: function EIO_onLocationFieldBlur() { - // XXXmano: uri fixup var uri; try { - uri = IO.newURI(this._element("locationField").value); + uri = PlacesUtils.createFixedURI(this._element("locationField").value); } catch(ex) { return; } @@ -522,10 +521,9 @@ var gEditItemOverlay = { }, onFeedLocationFieldBlur: function EIO_onFeedLocationFieldBlur() { - // XXXmano: uri fixup var uri; try { - uri = IO.newURI(this._element("feedLocationField").value); + uri = PlacesUtils.createFixedURI(this._element("feedLocationField").value); } catch(ex) { return; } @@ -537,10 +535,9 @@ var gEditItemOverlay = { }, onSiteLocationFieldBlur: function EIO_onSiteLocationFieldBlur() { - // XXXmano: uri fixup var uri = null; try { - uri = IO.newURI(this._element("siteLocationField").value); + uri = PlacesUtils.createFixedURI(this._element("siteLocationField").value); } catch(ex) { } diff --git a/browser/components/places/content/utils.js b/browser/components/places/content/utils.js index 8a3eafee431..ce2a87e50b8 100644 --- a/browser/components/places/content/utils.js +++ b/browser/components/places/content/utils.js @@ -183,6 +183,12 @@ var PlacesUtils = { getService(Ci.nsIClipboard); }, + get URIFixup() { + delete this.URIFixup; + return this.URIFixup = Cc["@mozilla.org/docshell/urifixup;1"]. + getService(Ci.nsIURIFixup); + }, + /** * Makes a URI from a spec. * @param aSpec @@ -194,6 +200,16 @@ var PlacesUtils = { return IO.newURI(aSpec); }, + /** + * Makes a URI from a spec, and do fixup + * @param aSpec + * The string spec of the URI + * @returns A URI object for the spec. + */ + createFixedURI: function PU_createFixedURI(aSpec) { + return this.URIFixup.createFixupURI(aSpec, 0); + }, + /** * Wraps a string in a nsISupportsString wrapper * @param aString