Make XUL error pages work again by making GetOrigin() return the full spec for chrome: URIs and preventing principal lookups when the principals hash is empty.
r+sr=jst@netscape.com
a=rjesup@wgate.com
This commit is contained in:
caillon%returnzero.com 2003-08-10 02:26:11 +00:00
Родитель e3cdfbf901
Коммит c2d2462e51
2 изменённых файлов: 31 добавлений и 18 удалений

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

@ -140,8 +140,18 @@ nsPrincipal::GetOrigin(char **aOrigin)
NS_ASSERTION(uri, "No Domain or Codebase");
nsCAutoString hostPort;
nsresult rv = uri->GetHostPort(hostPort);
if (NS_SUCCEEDED(rv)) {
// chrome: URLs don't have a meaningful origin, so make
// sure we just get the full spec for them.
// XXX this should be removed in favor of the solution in
// bug 160042.
PRBool isChrome;
nsresult rv = uri->SchemeIs("chrome", &isChrome);
if (NS_SUCCEEDED(rv) && !isChrome) {
rv = uri->GetHostPort(hostPort);
}
if (NS_SUCCEEDED(rv) && !isChrome) {
nsCAutoString scheme;
rv = uri->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -1654,25 +1654,28 @@ nsScriptSecurityManager::GetCodebasePrincipal(nsIURI *aURI,
rv = CreateCodebasePrincipal(aURI, getter_AddRefs(principal));
if (NS_FAILED(rv)) return rv;
//-- Check to see if we already have this principal.
nsCOMPtr<nsIPrincipal> fromTable;
mPrincipals.Get(principal, getter_AddRefs(fromTable));
if (fromTable)
principal = fromTable;
else //-- Check to see if we have a more general principal
if (mPrincipals.Count() > 0)
{
nsXPIDLCString originUrl;
rv = principal->GetOrigin(getter_Copies(originUrl));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> newURI;
rv = NS_NewURI(getter_AddRefs(newURI), originUrl, nsnull, sIOService);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrincipal> principal2;
rv = CreateCodebasePrincipal(newURI, getter_AddRefs(principal2));
if (NS_FAILED(rv)) return rv;
mPrincipals.Get(principal2, getter_AddRefs(fromTable));
//-- Check to see if we already have this principal.
nsCOMPtr<nsIPrincipal> fromTable;
mPrincipals.Get(principal, getter_AddRefs(fromTable));
if (fromTable)
principal = fromTable;
else //-- Check to see if we have a more general principal
{
nsXPIDLCString originUrl;
rv = principal->GetOrigin(getter_Copies(originUrl));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> newURI;
rv = NS_NewURI(getter_AddRefs(newURI), originUrl, nsnull, sIOService);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrincipal> principal2;
rv = CreateCodebasePrincipal(newURI, getter_AddRefs(principal2));
if (NS_FAILED(rv)) return rv;
mPrincipals.Get(principal2, getter_AddRefs(fromTable));
if (fromTable)
principal = fromTable;
}
}
NS_IF_ADDREF(*result = principal);