Bug 1461407 - make about:home unlinkable again and improve behavior of serialized principals across changes to URLs, r=bz,Mardak,mikedeboer

Making about:home unlinkable changes its URL structure. Prior to this change,
it is a nested URL. After this change, it no longer is.

We store serialized versions of principals in some cases. These include
details about whether the URI is nested etc. This is problematic for the
about:home change because the change in nesting changes the origin of the
page, so the origin  would mismatch between the principal and its URL.
To avoid this, we always re-create URIs for about: URIs when deserializing
them from strings, ensuring we don't create bogus principals.

MozReview-Commit-ID: 87zVUFgbusn

--HG--
extra : rebase_source : a7ad0dc3b1ea39521517da648f234d35d9a1729f
This commit is contained in:
Gijs Kruitbosch 2018-05-14 22:04:49 +01:00
parent 5c9362146d
commit faf68417dc
2 changed files with 9 additions and 1 deletions

View File

@ -84,7 +84,7 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
// Actual activity stream URL for home and newtab are set in channel creation
{ "home", "about:blank", ACTIVITY_STREAM_FLAGS | nsIAboutModule::MAKE_LINKABLE }, // Bug 1438367 to try removing MAKE_LINKABLE again
{ "home", "about:blank", ACTIVITY_STREAM_FLAGS },
{ "newtab", "about:blank", ACTIVITY_STREAM_FLAGS },
{ "welcome", "about:blank",
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |

View File

@ -420,6 +420,14 @@ ContentPrincipal::Read(nsIObjectInputStream* aStream)
}
codebase = do_QueryInterface(supports);
// Enforce re-parsing about: URIs so that if they change, we continue to use
// their new principals correctly.
bool isAbout = false;
if (NS_SUCCEEDED(codebase->SchemeIs("about", &isAbout)) && isAbout) {
nsAutoCString spec;
codebase->GetSpec(spec);
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(codebase), spec), NS_ERROR_FAILURE);
}
nsCOMPtr<nsIURI> domain;
rv = NS_ReadOptionalObject(aStream, true, getter_AddRefs(supports));