зеркало из https://github.com/mozilla/gecko-dev.git
Bug 441120 / bug 221445: don't split URLs on '|' when passed on the command line, r=mconnor, r=dveditz
This commit is contained in:
Родитель
a0350733cc
Коммит
986c32a684
|
@ -673,7 +673,13 @@ function BrowserStartup()
|
|||
gBrowser = document.getElementById("content");
|
||||
|
||||
var uriToLoad = null;
|
||||
// Check for window.arguments[0]. If present, use that for uriToLoad.
|
||||
|
||||
// window.arguments[0]: URI to load (string), or an nsISupportsArray of
|
||||
// nsISupportsStrings to load
|
||||
// [1]: character set (string)
|
||||
// [2]: referrer (nsIURI)
|
||||
// [3]: postData (nsIInputStream)
|
||||
// [4]: allowThirdPartyFixup (bool)
|
||||
if ("arguments" in window && window.arguments[0])
|
||||
uriToLoad = window.arguments[0];
|
||||
|
||||
|
@ -686,9 +692,26 @@ function BrowserStartup()
|
|||
#else
|
||||
# only load url passed in when we're not page cycling
|
||||
if (uriToLoad && !gIsLoadingBlank) {
|
||||
if (window.arguments.length >= 3)
|
||||
if (uriToLoad instanceof Components.interfaces.nsISupportsArray) {
|
||||
var count = uriToLoad.Count();
|
||||
var specs = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
var urisstring = uriToLoad.GetElementAt(i).QueryInterface(Components.interfaces.nsISupportsString);
|
||||
specs.push(urisstring.data);
|
||||
}
|
||||
|
||||
// This function throws for certain malformed URIs, so use exception handling
|
||||
// so that we don't disrupt startup
|
||||
try {
|
||||
gBrowser.loadTabs(specs, false, true);
|
||||
} catch (e) {}
|
||||
}
|
||||
else if (window.arguments.length >= 3) {
|
||||
loadURI(uriToLoad, window.arguments[2], window.arguments[3] || null,
|
||||
window.arguments[4] || false);
|
||||
}
|
||||
// Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.
|
||||
// Such callers expect that window.arguments[0] is handled as a single URI.
|
||||
else
|
||||
loadOneOrMoreURIs(uriToLoad);
|
||||
}
|
||||
|
@ -4308,7 +4331,9 @@ nsBrowserAccess.prototype =
|
|||
// FIXME: Bug 408379. So how come this doesn't send the
|
||||
// referrer like the other loads do?
|
||||
var url = aURI ? aURI.spec : "about:blank";
|
||||
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url);
|
||||
// Pass all params to openDialog to ensure that "url" isn't passed through
|
||||
// loadOneOrMoreURIs, which splits based on "|"
|
||||
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url, null, null, null);
|
||||
break;
|
||||
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
|
||||
var win = this._getMostRecentBrowserWindow();
|
||||
|
|
|
@ -176,17 +176,60 @@ function copyPrefOverride() {
|
|||
}
|
||||
}
|
||||
|
||||
function openWindow(parent, url, target, features, args) {
|
||||
// Flag used to indicate that the arguments to openWindow can be passed directly.
|
||||
const NO_EXTERNAL_URIS = 1;
|
||||
|
||||
function openWindow(parent, url, target, features, args, noExternalArgs) {
|
||||
var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(nsIWindowWatcher);
|
||||
|
||||
var argstring;
|
||||
if (args) {
|
||||
argstring = Components.classes["@mozilla.org/supports-string;1"]
|
||||
if (noExternalArgs == NO_EXTERNAL_URIS) {
|
||||
// Just pass in the defaultArgs directly
|
||||
var argstring;
|
||||
if (args) {
|
||||
argstring = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(nsISupportsString);
|
||||
argstring.data = args;
|
||||
argstring.data = args;
|
||||
}
|
||||
|
||||
return wwatch.openWindow(parent, url, target, features, argstring);
|
||||
}
|
||||
return wwatch.openWindow(parent, url, target, features, argstring);
|
||||
|
||||
// Pass an array to avoid the browser "|"-splitting behavior.
|
||||
var argArray = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// add args to the arguments array
|
||||
var stringArgs = null;
|
||||
if (args instanceof Array) // array
|
||||
stringArgs = args;
|
||||
else if (args) // string
|
||||
stringArgs = [args];
|
||||
|
||||
if (stringArgs) {
|
||||
// put the URIs into argArray
|
||||
var uriArray = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
stringArgs.forEach(function (uri) {
|
||||
var sstring = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(nsISupportsString);
|
||||
sstring.data = uri;
|
||||
uriArray.AppendElement(sstring);
|
||||
});
|
||||
argArray.AppendElement(uriArray);
|
||||
} else {
|
||||
argArray.AppendElement(null);
|
||||
}
|
||||
|
||||
// Pass these as null to ensure that we always trigger the "single URL"
|
||||
// behavior in browser.js's BrowserStartup (which handles the window
|
||||
// arguments)
|
||||
argArray.AppendElement(null); // charset
|
||||
argArray.AppendElement(null); // referer
|
||||
argArray.AppendElement(null); // postData
|
||||
argArray.AppendElement(null); // allowThirdPartyFixup
|
||||
|
||||
return wwatch.openWindow(parent, url, target, features, argArray);
|
||||
}
|
||||
|
||||
function openPreferences() {
|
||||
|
@ -316,9 +359,10 @@ var nsBrowserContentHandler = {
|
|||
/* nsICommandLineHandler */
|
||||
handle : function bch_handle(cmdLine) {
|
||||
if (cmdLine.handleFlag("browser", false)) {
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + this.getFeatures(cmdLine),
|
||||
this.defaultArgs);
|
||||
this.defaultArgs, NO_EXTERNAL_URIS);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
|
||||
|
@ -379,9 +423,10 @@ var nsBrowserContentHandler = {
|
|||
if (remoteParams[0].toLowerCase() != "openbrowser")
|
||||
throw NS_ERROR_ABORT;
|
||||
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + this.getFeatures(cmdLine),
|
||||
this.defaultArgs);
|
||||
this.defaultArgs, NO_EXTERNAL_URIS);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -442,7 +487,7 @@ var nsBrowserContentHandler = {
|
|||
var netutil = Components.classes["@mozilla.org/network/util;1"]
|
||||
.getService(nsINetUtil);
|
||||
if (!netutil.URIChainHasFlags(uri, URI_INHERITS_SECURITY_CONTEXT)) {
|
||||
openWindow(null, uri.spec, "_blank", features, "");
|
||||
openWindow(null, uri.spec, "_blank", features);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
}
|
||||
|
@ -774,23 +819,19 @@ var nsDefaultCommandLineHandler = {
|
|||
}
|
||||
}
|
||||
|
||||
var speclist = [];
|
||||
for (uri in urilist) {
|
||||
if (shouldLoadURI(urilist[uri]))
|
||||
speclist.push(urilist[uri].spec);
|
||||
}
|
||||
|
||||
if (speclist.length) {
|
||||
var URLlist = urilist.filter(shouldLoadURI).map(function (u) u.spec);
|
||||
if (URLlist.length) {
|
||||
openWindow(null, nsBrowserContentHandler.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + nsBrowserContentHandler.getFeatures(cmdLine),
|
||||
speclist.join("|"));
|
||||
URLlist);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!cmdLine.preventDefault) {
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, nsBrowserContentHandler.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + nsBrowserContentHandler.getFeatures(cmdLine),
|
||||
nsBrowserContentHandler.defaultArgs);
|
||||
nsBrowserContentHandler.defaultArgs, NO_EXTERNAL_URIS);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче