Bug 378685 - Permission manager should operate on innermost URI, r=dveditz sr=mconnor
authordcamp@mozilla.com
Thu, 21 Jun 2007 09:32:46 -0700
changeset 2640 3644e83de39cdb7ee8ecdc55dfbcf2362056a105
parent 2639 71ec39697f5fa1b99e5eb118f07d5257e0211a9c
child 2641 0618bb392a4c77fdadac3a539d4d9376d714ebd3
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdveditz, mconnor
bugs378685
milestone1.9a6pre
Bug 378685 - Permission manager should operate on innermost URI, r=dveditz sr=mconnor
extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -987,22 +987,25 @@ nsPermissionManager::Write()
 
   mChangedList = PR_FALSE;
   return NS_OK;
 }
 
 nsresult
 nsPermissionManager::GetHost(nsIURI *aURI, nsACString &aResult)
 {
-  aURI->GetHost(aResult);
+  nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(aURI);
+  if (!innerURI) return NS_ERROR_FAILURE;
+
+  innerURI->GetHost(aResult);
 
   // If there is no host, use the scheme, and prepend "scheme:",
   // to make sure it isn't a host or something.
   if (aResult.IsEmpty()) {
-    aURI->GetScheme(aResult);
+    innerURI->GetScheme(aResult);
     if (aResult.IsEmpty()) {
       // still empty. Return error.
       return NS_ERROR_FAILURE;
     }
     aResult = NS_LITERAL_CSTRING("scheme:") + aResult;
   }
 
   return NS_OK;