Make nsPrincipal::Equals compare codebases, not just certs, for certificate

principals.  Bug 369201, r=dveditz, sr=jst
This commit is contained in:
bzbarsky@mit.edu 2007-06-18 08:01:53 -07:00
Родитель 5594639fe8
Коммит ec536a72cf
1 изменённых файлов: 20 добавлений и 2 удалений

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

@ -265,8 +265,26 @@ nsPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult)
aOther->GetSubjectName(str);
*aResult = str.Equals(mCert->subjectName) || str.IsEmpty();
}
return NS_OK;
if (!*aResult) {
return NS_OK;
}
// If either principal has no URI, it's the saved principal from
// preferences; in that case, test true. Do NOT test true if the two
// principals have URIs with different codebases.
nsCOMPtr<nsIURI> otherURI;
nsresult rv = aOther->GetURI(getter_AddRefs(otherURI));
if (NS_FAILED(rv)) {
*aResult = PR_FALSE;
return rv;
}
if (!otherURI || !mCodebase) {
return NS_OK;
}
// Fall through to the codebase comparison.
}
// Codebases are equal if they have the same origin.