mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1277685, r=jaws
MozReview-Commit-ID: BtZCFTIdlMh --HG-- extra : rebase_source : d5e780066ec58b82a46a79ad6a0ee16c1e2bffe3
This commit is contained in:
parent
7eeaa7b6cd
commit
825b101112
@ -512,16 +512,13 @@ GenericProtocolHandler.prototype = {
|
||||
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;
|
||||
},
|
||||
|
@ -35,7 +35,9 @@ function run_test() {
|
||||
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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user