Bug 1848783, part 3 - Add the site (sans port) to the permission keys of a content process - r=anti-tracking-reviewers,timhuang

without this, permissions set in the main process that are site-scoped on origins with non-null ports are not pushed out to the content process.

Differential Revision: https://phabricator.services.mozilla.com/D186984
This commit is contained in:
Benjamin VanderSloot 2023-09-19 11:11:19 +00:00
Родитель e23a54c68e
Коммит 9603be41ae
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -3439,6 +3439,7 @@ PermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
nsTArray<std::pair<nsCString, nsCString>> pairs;
nsCOMPtr<nsIPrincipal> prin = aPrincipal;
while (prin) {
// Add the pair to the list
std::pair<nsCString, nsCString>* pair =
@ -3461,6 +3462,17 @@ PermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal) {
// Get the next subdomain principal and loop back around.
}
// We need to add the Site to the keys of interest here.
// This allows site-scoped permissions to propogate
// even when the origin has a non-standard port.
nsCString siteKey;
nsresult rv = GetKeyForPrincipal(aPrincipal, false, true, siteKey);
if (NS_SUCCEEDED(rv) && !siteKey.IsEmpty()) {
std::pair<nsCString, nsCString>* pair =
pairs.AppendElement(std::make_pair(siteKey, ""_ns));
Unused << GetSiteFromPrincipal(aPrincipal, false, pair->second);
}
MOZ_ASSERT(pairs.Length() >= 1,
"Every principal should have at least one pair item.");
return pairs;