Bug 817007 - Part 1: Remove <file> hack from the permission manager, r=ehsan

This commit is contained in:
Michael Layzell 2015-06-16 15:52:57 -04:00 committed by Ehsan Akhgari
parent ac17bea4d9
commit b851ab728f
2 changed files with 0 additions and 19 deletions

View File

@ -1439,19 +1439,6 @@ nsPermissionManager::GetPermissionHashKey(const nsACString& aHost,
return entry;
}
// If we haven't found an entry, depending on the host, we could try a bit
// harder.
// If this is a file:// URI, we can check for the presence of the magic entry
// <file> which gives permission to all file://. This hack might disappear,
// see bug 817007. Note that we don't require aExactHostMatch to be true for
// that to keep retro-compatibility.
// If this is not a file:// URI, and that aExactHostMatch wasn't true, we can
// check if the base domain has a permission entry.
if (StringBeginsWith(aHost, NS_LITERAL_CSTRING("file://"))) {
return GetPermissionHashKey(NS_LITERAL_CSTRING("<file>"), aAppId, aIsInBrowserElement, aType, true);
}
// If aExactHostMatch wasn't true, we can check if the base domain has a permission entry.
if (!aExactHostMatch) {
nsCString domain = GetNextSubDomainForHost(aHost);

View File

@ -39,10 +39,4 @@ function run_test() {
do_check_eq(pm.testPermissionFromPrincipal(principal, "test/local-files"), pm.UNKNOWN_ACTION);
do_check_eq(pm.testPermissionFromPrincipal(witnessPrincipal, "test/local-files"), pm.UNKNOWN_ACTION);
do_check_eq(pm.testPermissionFromPrincipal(fileInDirPrincipal, "test/local-files"), pm.UNKNOWN_ACTION);
// Add the magic "<file>" permission and make sure all "file://" now have the permission.
pm.addFromPrincipal(getPrincipalFromURIString("http://<file>"), "test/local-files", pm.ALLOW_ACTION, 0, 0);
do_check_eq(pm.testPermissionFromPrincipal(principal, "test/local-files"), pm.ALLOW_ACTION);
do_check_eq(pm.testPermissionFromPrincipal(witnessPrincipal, "test/local-files"), pm.ALLOW_ACTION);
do_check_eq(pm.testPermissionFromPrincipal(fileInDirPrincipal, "test/local-files"), pm.ALLOW_ACTION);
}