Bug 1277685, r=jaws, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 07 Jun 2016 14:53:34 +0100
changeset 341680 050a2562452ab607ca00176f1cb8277e01f17a38
parent 341679 e627ab32ecfb8947a634d53ed59567919c464417
child 341681 c40ae6d6fb9938bc774d7d07fcf393e87aeb05dc
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, sylvestre
bugs1277685
milestone49.0a2
Bug 1277685, r=jaws, a=sylvestre MozReview-Commit-ID: BtZCFTIdlMh
browser/components/feeds/FeedConverter.js
browser/components/feeds/test/unit/test_355473.js
--- a/browser/components/feeds/FeedConverter.js
+++ b/browser/components/feeds/FeedConverter.js
@@ -506,26 +506,23 @@ GenericProtocolHandler.prototype = {
     // case we create a nested URI for the realURI) or feed://example.com, in
     // which case we create a nested URI for the real protocol which is http.
 
     let scheme = this._scheme + ":";
     if (spec.substr(0, scheme.length) != scheme)
       throw Cr.NS_ERROR_MALFORMED_URI;
 
     let prefix = spec.substr(scheme.length, 2) == "//" ? "http:" : "";
-    let inner = Cc["@mozilla.org/network/io-service;1"].
-                getService(Ci.nsIIOService).newURI(spec.replace(scheme, prefix),
-                                                   originalCharset, baseURI);
-    let netutil = Cc["@mozilla.org/network/util;1"].getService(Ci.nsINetUtil);
-    const URI_INHERITS_SECURITY_CONTEXT = Ci.nsIProtocolHandler
-                                            .URI_INHERITS_SECURITY_CONTEXT;
-    if (netutil.URIChainHasFlags(inner, URI_INHERITS_SECURITY_CONTEXT))
+    let inner = Services.io.newURI(spec.replace(scheme, prefix),
+                                   originalCharset, baseURI);
+
+    if (!["http", "https"].includes(inner.scheme))
       throw Cr.NS_ERROR_MALFORMED_URI;
 
-    let uri = netutil.newSimpleNestedURI(inner);
+    let uri = Services.io.QueryInterface(Ci.nsINetUtil).newSimpleNestedURI(inner);
     uri.spec = inner.spec.replace(prefix, scheme);
     return uri;
   },
 
   newChannel2(aUri, aLoadInfo) {
     let inner = aUri.QueryInterface(Ci.nsINestedURI).innerURI;
     let channel = Cc["@mozilla.org/network/io-service;1"].
                   getService(Ci.nsIIOService).
--- a/browser/components/feeds/test/unit/test_355473.js
+++ b/browser/components/feeds/test/unit/test_355473.js
@@ -30,12 +30,14 @@ function run_test() {
   do_check_true(httpFeedURI.equals(httpChannel.originalURI));
   do_check_true(httpsFeedURI.equals(httpsChannel.originalURI));
 
   // actually using the horrible mess that's a feed: URI is suicidal
   do_check_true(httpURI.equals(feedChannel.URI));
   do_check_true(httpURI.equals(httpChannel.URI));
   do_check_true(httpsURI.equals(httpsChannel.URI));
 
-  // check that we don't throw creating feed: URIs from file and ftp
-  var ftpFeedURI = ios.newURI("feed:ftp://example.com/feed.xml", null, null);
-  var fileFeedURI = ios.newURI("feed:file:///var/feed.xml", null, null);
+  // check that we throw creating feed: URIs from file and ftp
+  Assert.throws(function() { ios.newURI("feed:ftp://example.com/feed.xml", null, null); },
+      "Should throw an exception when trying to create a feed: URI with an ftp: inner");
+  Assert.throws(function() { ios.newURI("feed:file:///var/feed.xml", null, null); },
+      "Should throw an exception when trying to create a feed: URI with a file: inner");
 }