Bug 1018589 - Can't add RSS feed with Cyrillic URL -> support idn urls for feeds. r=mkmelin
authoralta88
Fri, 13 Jun 2014 08:44:20 -0600
changeset 16346 57bcf6cc9e8aadbf2e2e6f96c1d7b6b3759c9152
parent 16345 852267c1a3571cf0f95c13e634bc3720da8deee1
child 16347 1c84ef2f69f9865429b5b3f533b19cd6c88d64e8
push id10215
push userryanvm@gmail.com
push dateWed, 18 Jun 2014 15:45:10 +0000
treeherdercomm-central@fdf6199b3ea9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1018589
Bug 1018589 - Can't add RSS feed with Cyrillic URL -> support idn urls for feeds. r=mkmelin
mail/base/content/mailWindowOverlay.js
mailnews/extensions/newsblog/content/Feed.js
mailnews/extensions/newsblog/content/FeedUtils.jsm
mailnews/extensions/newsblog/content/feed-parser.js
mailnews/extensions/newsblog/content/feed-subscriptions.js
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -3587,16 +3587,20 @@ let FeedMessageHandler = {
    *                                  'messagepane', 'browser', 'tab', 'window'.
    */
   loadWebPage: function (aMessageHdr, aWhere) {
     MsgHdrToMimeMessage(aMessageHdr, null, function(aMsgHdr, aMimeMsg) {
       if (aMimeMsg && aMimeMsg.headers["content-base"] &&
           aMimeMsg.headers["content-base"][0]) {
         let url = aMimeMsg.headers["content-base"], uri;
         try {
+          let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
+                            .createInstance(Ci.nsIScriptableUnicodeConverter);
+          converter.charset = "UTF-8";
+          url = converter.ConvertToUnicode(url);
           uri = Services.io.newURI(url, null, null);
           url = uri.spec;
         }
         catch (ex) {
           FeedUtils.log.info("FeedMessageHandler.loadWebPage: " +
                              "invalid Content-Base header url - " + url);
           return;
         }
--- a/mailnews/extensions/newsblog/content/Feed.js
+++ b/mailnews/extensions/newsblog/content/Feed.js
@@ -246,17 +246,17 @@ Feed.prototype =
 
   get url()
   {
     let ds = FeedUtils.getSubscriptionsDS(this.server);
     let url = ds.GetTarget(this.resource, FeedUtils.DC_IDENTIFIER, true);
     if (url)
       url = url.QueryInterface(Ci.nsIRDFLiteral).Value;
     else
-      url = this.resource.Value;
+      url = this.resource.ValueUTF8;
 
     return url;
   },
 
   get title()
   {
     let ds = FeedUtils.getSubscriptionsDS(this.server);
     let title = ds.GetTarget(this.resource, FeedUtils.DC_TITLE, true);
--- a/mailnews/extensions/newsblog/content/FeedUtils.jsm
+++ b/mailnews/extensions/newsblog/content/FeedUtils.jsm
@@ -273,17 +273,17 @@ var FeedUtils = {
 
     // Get the list from the feeds database.
     try {
       let ds = this.getSubscriptionsDS(aFolder.server);
       let enumerator = ds.GetSources(this.FZ_DESTFOLDER, aFolder, true);
       while (enumerator.hasMoreElements())
       {
         let containerArc = enumerator.getNext();
-        let uri = containerArc.QueryInterface(Ci.nsIRDFResource).Value;
+        let uri = containerArc.QueryInterface(Ci.nsIRDFResource).ValueUTF8;
         feedUrlArray.push(uri);
       }
     }
     catch(ex)
     {
       this.log.error("getFeedUrlsInFolder: feeds.rdf db error - " + ex);
       this.log.error("getFeedUrlsInFolder: feeds.rdf db error for account - " +
                      aFolder.server.serverURI + " : " + aFolder.server.prettyName);
--- a/mailnews/extensions/newsblog/content/feed-parser.js
+++ b/mailnews/extensions/newsblog/content/feed-parser.js
@@ -335,17 +335,17 @@ FeedParser.prototype =
     while (items.hasMoreElements())
     {
       let itemResource = items.getNext().QueryInterface(Ci.nsIRDFResource);
       let item = new FeedItem();
       item.feed = aFeed;
 
       // Prefer the value of the link tag to the item URI since the URI could be
       // a relative URN.
-      let uri = itemResource.Value;
+      let uri = itemResource.ValueUTF8;
       let link = this.getRDFTargetValue(ds, itemResource, FeedUtils.RSS_LINK);
       item.url = link || uri;
       item.description = this.getRDFTargetValue(ds, itemResource,
                                                 FeedUtils.RSS_DESCRIPTION);
       item.title = this.getRDFTargetValue(ds, itemResource, FeedUtils.RSS_TITLE) ||
                    this.getRDFTargetValue(ds, itemResource, FeedUtils.DC_SUBJECT) ||
                    (item.description ?
                      (this.stripTags(item.description).substr(0, 150)) : null);
--- a/mailnews/extensions/newsblog/content/feed-subscriptions.js
+++ b/mailnews/extensions/newsblog/content/feed-subscriptions.js
@@ -1393,17 +1393,17 @@ var FeedSubscriptions = {
 
     if (!itemToEdit || itemToEdit.container || !itemToEdit.parentFolder)
       return;
 
     let resource = FeedUtils.rdf.GetResource(itemToEdit.url);
     let currentFolderServer = itemToEdit.parentFolder.server;
     let ds = FeedUtils.getSubscriptionsDS(currentFolderServer);
     let currentFolder = ds.GetTarget(resource, FeedUtils.FZ_DESTFOLDER, true);
-    let currentFolderURI = currentFolder.QueryInterface(Ci.nsIRDFResource).Value;
+    let currentFolderURI = currentFolder.QueryInterface(Ci.nsIRDFResource).ValueUTF8;
     let feed = new Feed(resource, currentFolderServer);
     feed.folder = itemToEdit.parentFolder;
 
     let editNameValue = document.getElementById("nameValue").value;
     let editFeedLocation = document.getElementById("locationValue").value.trim();
     let selectFolder = document.getElementById("selectFolder");
     let editQuickMode = document.getElementById("quickMode").checked;
     let editAutotagPrefix = document.getElementById("autotagPrefix").value;