Bug 336519 Need to be more careful when loading some URIs into existing windows r=jag sr=biesi
git-svn-id: svn://10.0.0.236/trunk@233082 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -622,7 +622,7 @@ nsContextMenu.prototype = {
|
||||
},
|
||||
// Open clicked-in frame in the same window
|
||||
showOnlyThisFrame : function () {
|
||||
window.loadURI(this.target.ownerDocument.location.href);
|
||||
openTopWin( this.target.ownerDocument.location.href, this.target.ownerDocument.defaultView );
|
||||
},
|
||||
// View Partial Source
|
||||
viewPartialSource : function ( context ) {
|
||||
@@ -671,12 +671,12 @@ nsContextMenu.prototype = {
|
||||
// Change current window to the URL of the image.
|
||||
viewImage : function () {
|
||||
urlSecurityCheck( this.imageURL, document );
|
||||
openTopWin( this.imageURL );
|
||||
openTopWin( this.imageURL, this.target.ownerDocument.defaultView );
|
||||
},
|
||||
// Change current window to the URL of the background image.
|
||||
viewBGImage : function () {
|
||||
urlSecurityCheck( this.bgImageURL, document );
|
||||
openTopWin( this.bgImageURL );
|
||||
openTopWin( this.bgImageURL, this.target.ownerDocument.defaultView );
|
||||
},
|
||||
setWallpaper: function() {
|
||||
// Confirm since it's annoying if you hit this accidentally.
|
||||
|
||||
@@ -329,7 +329,20 @@ function getTopWin()
|
||||
return null;
|
||||
}
|
||||
|
||||
function openTopWin( url )
|
||||
function isRestricted( url )
|
||||
{
|
||||
try {
|
||||
const nsIURIFixup = Components.interfaces.nsIURIFixup;
|
||||
var uriFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
|
||||
.getService(nsIURIFixup);
|
||||
var url = uriFixup.createFixupURI(url, nsIURIFixup.FIXUP_FLAG_NONE);
|
||||
return url.schemeIs("javascript") || url.schemeIs("data");
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function openTopWin( url, opener )
|
||||
{
|
||||
/* note that this chrome url should probably change to not have
|
||||
all of the navigator controls, but if we do this we need to have
|
||||
@@ -347,8 +360,15 @@ function openTopWin( url )
|
||||
var topWindowOfType = getTopWin();
|
||||
if ( topWindowOfType )
|
||||
{
|
||||
topWindowOfType.focus();
|
||||
topWindowOfType.loadURI(url);
|
||||
if (opener && topWindowOfType.content == opener.top)
|
||||
opener.open(url, "_top");
|
||||
else if (opener && isRestricted(url))
|
||||
topWindowOfType.getBrowser().loadURIWithFlags(url,
|
||||
Components.interfaces.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL);
|
||||
else
|
||||
topWindowOfType.loadURI(url);
|
||||
|
||||
topWindowOfType.content.focus();
|
||||
return topWindowOfType;
|
||||
}
|
||||
return window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );
|
||||
|
||||
Reference in New Issue
Block a user