From 204853b891a20f8d260e9fc791a2a472b9c9221f Mon Sep 17 00:00:00 2001 From: John Foerch Date: Fri, 14 Oct 2011 01:30:21 -0400 Subject: [PATCH] set_protocol_handlers: fix it, resolving issue372 We were experiencing a problem where simply registering a mailto handler would later cause following a link a pdf to segfault. Full details at bug report url, given below. It turned out to be caused by a careless error in the call form for getting the service nsIExternalProtocolService. (I had copy-pasted that line from an example somewhere, an example which was, it turns out, incorrect.) Also clear the 'possibleApplicationHandlers' list, so it doesn't grow and grow. http://bugs.conkeror.org/issue372 --- modules/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/utils.js b/modules/utils.js index f0c9846..6d682ff 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -887,8 +887,7 @@ function evaluate (s) { */ function set_protocol_handler (protocol, handler) { var eps = Cc["@mozilla.org/uriloader/external-protocol-service;1"] - .createInstance() - .QueryInterface(Ci.nsIExternalProtocolService); + .getService(Ci.nsIExternalProtocolService); var info = eps.getProtocolHandlerInfo(protocol); var expose_pref = "network.protocol-handler.expose."+protocol; if (handler == true) { @@ -909,6 +908,8 @@ function set_protocol_handler (protocol, handler) { } info.alwaysAskBeforeHandling = false; info.preferredAction = Ci.nsIHandlerInfo.useHelperApp; + info.possibleApplicationHandlers.clear(); + info.possibleApplicationHandlers.appendElement(h, false); info.preferredApplicationHandler = h; session_pref(expose_pref, false); } else { -- 2.11.4.GIT