From eb4a8063aa5341c68d9341ee536d675c12e1b179 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 29 Jun 2006 18:26:53 +0000 Subject: [PATCH] Use the principal of the node, not the URI, for the security check. Bug 343065, r+sr=peterv, a=schrep git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@201249 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDOMSerializer.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mozilla/content/base/src/nsDOMSerializer.cpp b/mozilla/content/base/src/nsDOMSerializer.cpp index 5115f7d56b5..d5a44a1180c 100644 --- a/mozilla/content/base/src/nsDOMSerializer.cpp +++ b/mozilla/content/base/src/nsDOMSerializer.cpp @@ -154,15 +154,9 @@ CheckSameOrigin(nsIDOMNode *aRoot) } } - nsCOMPtr root_uri; - nsIPrincipal *principal = doc->GetPrincipal(); if (principal) { - principal->GetURI(getter_AddRefs(root_uri)); - } - - if (root_uri) { nsresult rv; nsCOMPtr secMan = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); @@ -178,9 +172,16 @@ CheckSameOrigin(nsIDOMNode *aRoot) return NS_OK; } - // Check if the caller (if any) is from the same origin that the - // root is from. - return secMan->CheckSameOrigin(nsnull, root_uri); + nsCOMPtr subject; + rv = secMan->GetSubjectPrincipal(getter_AddRefs(subject)); + NS_ENSURE_SUCCESS(rv, rv); + + // Since UBR is not enabled, we better have a subject principal, + // but just in case... + if (subject) { + // Check if the caller is from the same origin that the root is from. + return secMan->CheckSameOriginPrincipal(subject, principal); + } } return NS_OK;