зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1570159 - CreatePairwiseWhitelistURI return success when it cannot get host from the top-level page. r=Ehsan
Before this patch, when we cannot get the host name from the top-level page, for example, aboout page, UrlClassifeirCommon::CreatePairwiseWhitelistURI returns an error. After this patch, when |GetHost| fails, we returns NS_OK to just skip looking up whiltelist for this URI. Note that the lookup against blacklist tables will still be performed. Differential Revision: https://phabricator.services.mozilla.com/D49983 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d99cac29b3
Коммит
3937de1977
|
@ -707,16 +707,22 @@ nsresult FeatureData::InitializeList(
|
||||||
nsIUrlClassifierFeature::URIType URIType;
|
nsIUrlClassifierFeature::URIType URIType;
|
||||||
nsresult rv = mFeature->GetURIByListType(aChannel, aListType, &URIType,
|
nsresult rv = mFeature->GetURIByListType(aChannel, aListType, &URIType,
|
||||||
getter_AddRefs(uri));
|
getter_AddRefs(uri));
|
||||||
if (NS_WARN_IF(NS_FAILED(rv)) || !uri) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
if (UC_LOG_ENABLED()) {
|
if (UC_LOG_ENABLED()) {
|
||||||
nsAutoCString errorName;
|
nsAutoCString errorName;
|
||||||
GetErrorName(rv, errorName);
|
GetErrorName(rv, errorName);
|
||||||
UC_LOG(("FeatureData::InitializeList got an unexpected error (rv=%s)",
|
UC_LOG(("FeatureData::InitializeList[%p] got an unexpected error (rv=%s)",
|
||||||
errorName.get()));
|
this, errorName.get()));
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!uri) {
|
||||||
|
// Return success when the URI is empty to conitnue to do the lookup.
|
||||||
|
UC_LOG(("FeatureData::InitializeList[%p] got an empty URL", this));
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> innermostURI = NS_GetInnermostURI(uri);
|
nsCOMPtr<nsIURI> innermostURI = NS_GetInnermostURI(uri);
|
||||||
if (NS_WARN_IF(!innermostURI)) {
|
if (NS_WARN_IF(!innermostURI)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
|
@ -338,7 +338,17 @@ nsresult UrlClassifierCommon::CreatePairwiseWhiteListURI(nsIChannel* aChannel,
|
||||||
// Craft a whitelist URL like "toplevel.page/?resource=third.party.domain"
|
// Craft a whitelist URL like "toplevel.page/?resource=third.party.domain"
|
||||||
nsAutoCString pageHostname, resourceDomain;
|
nsAutoCString pageHostname, resourceDomain;
|
||||||
rv = topWinURI->GetHost(pageHostname);
|
rv = topWinURI->GetHost(pageHostname);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
// When the top-level page doesn't support GetHost, for example, about:home,
|
||||||
|
// we don't return an error here; instead, we return success to make sure
|
||||||
|
// that the lookup process calling this API continues to run.
|
||||||
|
UC_LOG(
|
||||||
|
("CreatePairwiseWhiteListURI: Cannot get host from the top-level "
|
||||||
|
"(channel=%p)",
|
||||||
|
aChannel));
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
rv = chanPrincipal->GetBaseDomain(resourceDomain);
|
rv = chanPrincipal->GetBaseDomain(resourceDomain);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
nsAutoCString whitelistEntry = NS_LITERAL_CSTRING("http://") + pageHostname +
|
nsAutoCString whitelistEntry = NS_LITERAL_CSTRING("http://") + pageHostname +
|
||||||
|
|
Загрузка…
Ссылка в новой задаче