Bug 1331751 - Fix the use of nsIURIWithPrincipal in nsPrincipal::GetOriginInternal, r=bkelly
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 18 Jan 2017 15:52:24 +0100
changeset 374951 a26555efc6e55329fd02217f5585658db3ed91df
parent 374950 c6e104aef85f2ee6831ce1e6b38c4127ef08d125
child 374952 eb6cd64d4a67b8342673a19412588ee834e77f5f
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1331751
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1331751 - Fix the use of nsIURIWithPrincipal in nsPrincipal::GetOriginInternal, r=bkelly
caps/nsPrincipal.cpp
--- a/caps/nsPrincipal.cpp
+++ b/caps/nsPrincipal.cpp
@@ -164,17 +164,20 @@ nsPrincipal::GetOriginInternal(nsACStrin
     return NS_OK;
   }
 
   // This URL can be a blobURL. In this case, we should use the 'parent'
   // principal instead.
   nsCOMPtr<nsIURIWithPrincipal> uriWithPrincipal = do_QueryInterface(origin);
   if (uriWithPrincipal) {
     nsCOMPtr<nsIPrincipal> uriPrincipal;
-    if (uriWithPrincipal) {
+    rv = uriWithPrincipal->GetPrincipal(getter_AddRefs(uriPrincipal));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    if (uriPrincipal) {
       return uriPrincipal->GetOriginNoSuffix(aOrigin);
     }
   }
 
   // If we reached this branch, we can only create an origin if we have a
   // nsIStandardURL.  So, we query to a nsIStandardURL, and fail if we aren't
   // an instance of an nsIStandardURL nsIStandardURLs have the good property
   // of escaping the '^' character in their specs, which means that we can be