From ca23c546c99ea1cd228c6a381f234772e69ec195 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Fri, 14 Oct 2005 18:57:26 +0000 Subject: [PATCH] bug 312124: Make Subsume treat about:blank principals as being weaker than other, non-about:blank principals, since that's how other code treats them. r=caillon sr=brendan --- caps/src/nsPrincipal.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp index 7ea579ba64a2..39c703b437bc 100755 --- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -1,4 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 sw=2 et tw=80: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -277,6 +278,32 @@ nsPrincipal::Equals(nsIPrincipal *aOther, PRBool *aResult) NS_IMETHODIMP nsPrincipal::Subsumes(nsIPrincipal *aOther, PRBool *aResult) { + // First, check if aOther is an about:blank principal. If it is, then we can + // subsume it. + + nsCOMPtr otherOrigin; + aOther->GetURI(getter_AddRefs(otherOrigin)); + + if (otherOrigin) { + PRBool isAbout = PR_FALSE; + if (NS_SUCCEEDED(otherOrigin->SchemeIs("about", &isAbout)) && isAbout) { + nsCAutoString str; + otherOrigin->GetSpec(str); + + // Note: about:blank principals do not necessarily subsume about:blank + // principals (unless aOther == this, which is checked in the Equals call + // below). + + if (str.Equals("about:blank")) { + PRBool isEqual = PR_FALSE; + if (NS_SUCCEEDED(otherOrigin->Equals(mCodebase, &isEqual)) && !isEqual) { + *aResult = PR_TRUE; + return NS_OK; + } + } + } + } + return Equals(aOther, aResult); }