Bug 1043110 - Part 1 - Display a load error if we navigate to a page which is not claimed in |widgetPages|. r=bz
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "nsIDOMStorage.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsDOMCID.h"
|
||||
@@ -10402,6 +10403,32 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
||||
}
|
||||
}
|
||||
|
||||
// For mozWidget, display a load error if we navigate to a page which is not
|
||||
// claimed in |widgetPages|.
|
||||
if (mScriptGlobal) {
|
||||
// When we go to display a load error for an invalid mozWidget page, we will
|
||||
// try to load an about:neterror page, which is also an invalid mozWidget
|
||||
// page. To avoid recursion, we skip this check if aURI's scheme is "about".
|
||||
|
||||
// The goal is to prevent leaking sensitive information of an invalid page of
|
||||
// an app, so allowing about:blank would not be conflict to the goal.
|
||||
bool isAbout = false;
|
||||
rv = aURI->SchemeIs("about", &isAbout);
|
||||
if (NS_SUCCEEDED(rv) && !isAbout &&
|
||||
nsIDocShell::GetIsApp()) {
|
||||
nsCOMPtr<Element> frameElement = mScriptGlobal->GetFrameElementInternal();
|
||||
if (frameElement) {
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(frameElement);
|
||||
// |GetReallyIsApp| indicates the browser frame is a valid app or widget.
|
||||
// Here we prevent navigating to an app or widget which loses its validity
|
||||
// by loading invalid page or other way.
|
||||
if (browserFrame && !browserFrame->GetReallyIsApp()) {
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// open a channel for the url
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user