Skip to content

Commit

Permalink
Fix nsIProtocolHandler.newChannel() implementation: accept any URI to…
Browse files Browse the repository at this point in the history
… avoid crashes

(#94)
  • Loading branch information
Infocatcher committed Aug 24, 2013
1 parent 477fd25 commit 5ee0130
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@ var privateProtocol = {
newChannel: function(uri) {
var spec = uri.spec;
_log("[protocol] newChannel(): spec = " + spec);
if(!spec || !spec.startsWith(P_SCHEME + ":"))
return null;
var newSpec = spec.replace(/^private:\/*#?/i, "");
var newSpec = "";
var schemePrefix = P_SCHEME + ":";
// Example: private:///#https://addons.mozilla.org/
if(spec && spec.startsWith(schemePrefix))
newSpec = spec.substr(0, schemePrefix.length).replace(/^\/*#?/, "");
_log("[protocol] newChannel(): newSpec = " + newSpec);
try {
Services.io.newURI(newSpec, null, null);
}
catch(e) {
_log("[protocol] newChannel(): malformed URI");
Components.utils.reportError(e);
return null;
}

// We can't use newChannel(newSpec, ...) here - strange things happens
// Also we can't use nsIPrivateBrowsingChannel.setPrivate(true) for chrome:// URI
Expand Down

0 comments on commit 5ee0130

Please sign in to comment.