diff --git a/browser/components/feeds/src/WebContentConverter.js b/browser/components/feeds/src/WebContentConverter.js index 641c2275585..fb59bbe0548 100644 --- a/browser/components/feeds/src/WebContentConverter.js +++ b/browser/components/feeds/src/WebContentConverter.js @@ -62,6 +62,7 @@ const PREF_CONTENTHANDLERS_BRANCH = "browser.contentHandlers.types."; const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice"; const PREF_SELECTED_ACTION = "browser.feeds.handler"; const PREF_SELECTED_READER = "browser.feeds.handler.default"; +const PREF_HANDLER_EXTERNAL_PREFIX = "network.protocol-handler.external"; const PREF_ALLOW_DIFFERENT_HOST = "gecko.handlerService.allowRegisterFromDifferentHost"; const STRING_BUNDLE_URI = "chrome://browser/locale/feeds/subscribe.properties"; @@ -421,7 +422,21 @@ WebContentConverterRegistrar.prototype = { // isn't defined yet. throw("Permission denied to add " + aURIString + "as a protocol handler"); } - + + // check if it is in the black list + var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); + var allowed; + try { + allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol); + } + catch (e) { + allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default"); + } + if (!allowed) { + // XXX this should be a "security exception" according to spec + throw("Not allowed to register a protocol handler for " + aProtocol); + } + var uri = this._checkAndGetURI(aURIString, aContentWindow); var buttons, message; diff --git a/browser/components/feeds/test/Makefile.in b/browser/components/feeds/test/Makefile.in index d5d8fc04c43..1360a42b727 100644 --- a/browser/components/feeds/test/Makefile.in +++ b/browser/components/feeds/test/Makefile.in @@ -51,6 +51,7 @@ _TEST_FILES = test_bug408328.html \ bug408328-data.xml \ test_bug368464.html \ bug368464-data.xml \ + test_registerHandler.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/browser/components/feeds/test/test_registerHandler.html b/browser/components/feeds/test/test_registerHandler.html new file mode 100644 index 00000000000..1e2bc56fe53 --- /dev/null +++ b/browser/components/feeds/test/test_registerHandler.html @@ -0,0 +1,87 @@ + + + +
++ ++ +