Bug 1150703, allow about: pages to be unlinkable even if "safe for content", r=mcmanus, IGNORE IDL

This commit is contained in:
Gijs Kruitbosch 2015-04-03 09:59:00 +01:00
parent 66ad9e9b88
commit a3acdade4f
2 changed files with 19 additions and 5 deletions

View File

@ -28,6 +28,14 @@ static bool IsSafeForUntrustedContent(nsIAboutModule *aModule, nsIURI *aURI) {
return (flags & nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT) != 0;
}
static bool IsSafeToLinkForUntrustedContent(nsIAboutModule *aModule, nsIURI *aURI) {
uint32_t flags;
nsresult rv = aModule->GetURIFlags(aURI, &flags);
NS_ENSURE_SUCCESS(rv, false);
return (flags & nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT) && !(flags & nsIAboutModule::MAKE_UNLINKABLE);
}
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS(nsAboutProtocolHandler, nsIProtocolHandler)
@ -82,7 +90,7 @@ nsAboutProtocolHandler::NewURI(const nsACString &aSpec,
nsCOMPtr<nsIAboutModule> aboutMod;
rv = NS_GetAboutModule(url, getter_AddRefs(aboutMod));
if (NS_SUCCEEDED(rv)) {
isSafe = IsSafeForUntrustedContent(aboutMod, url);
isSafe = IsSafeToLinkForUntrustedContent(aboutMod, url);
}
if (isSafe) {

View File

@ -25,10 +25,10 @@ interface nsIAboutModule : nsISupports
/**
* A flag that indicates whether a URI is safe for untrusted
* content. If it is, web pages and so forth will be allowed to
* link to this about: URI, and the about: protocol handler will
* enforce that the principal of channels created for it be based
* on their originalURI or URI (depending on the channel flags),
* by setting their "owner" to null.
* link to this about: URI (unless MAKE_UNLINKABLE is also specified),
* and the about: protocol handler will enforce that the principal
* of channels created for it be based on their originalURI or URI
* (depending on the channel flags), by setting their "owner" to null.
* Otherwise, only chrome will be able to link to it.
*/
const unsigned long URI_SAFE_FOR_UNTRUSTED_CONTENT = (1 << 0);
@ -60,6 +60,12 @@ interface nsIAboutModule : nsISupports
*/
const unsigned long URI_MUST_LOAD_IN_CHILD = (1 << 5);
/**
* A flag that indicates that this URI should be unlinkable despite being
* safe for untrusted content.
*/
const unsigned long MAKE_UNLINKABLE = (1 << 6);
/**
* A method to get the flags that apply to a given about: URI. The URI
* passed in is guaranteed to be one of the URIs that this module