diff --git a/mozilla/dom/src/storage/Makefile.in b/mozilla/dom/src/storage/Makefile.in index eca7de11bca..858a0ac7942 100644 --- a/mozilla/dom/src/storage/Makefile.in +++ b/mozilla/dom/src/storage/Makefile.in @@ -55,6 +55,7 @@ REQUIRES = xpcom \ layout \ locale \ necko \ + jar \ pref \ unicharutil \ widget \ diff --git a/mozilla/dom/src/storage/nsDOMStorage.cpp b/mozilla/dom/src/storage/nsDOMStorage.cpp index 17432601593..f6c92c727be 100644 --- a/mozilla/dom/src/storage/nsDOMStorage.cpp +++ b/mozilla/dom/src/storage/nsDOMStorage.cpp @@ -49,6 +49,7 @@ #include "nsIURI.h" #include "nsReadableUtils.h" #include "nsIObserverService.h" +#include "nsIJARURI.h" // // Helper that tells us whether the caller is secure or not. @@ -57,21 +58,36 @@ static PRBool IsCallerSecure() { - nsCOMPtr callerDoc = - do_QueryInterface(nsContentUtils::GetDocumentFromCaller()); + nsCOMPtr subjectPrincipal; + nsContentUtils::GetSecurityManager()-> + GetSubjectPrincipal(getter_AddRefs(subjectPrincipal)); + + if (!subjectPrincipal) { + // No subject principal means no code is running. Default to not + // being secure in that case. - if (!callerDoc) { return PR_FALSE; } - nsIURI *uri = callerDoc->GetDocumentURI(); + nsCOMPtr codebase; + subjectPrincipal->GetURI(getter_AddRefs(codebase)); - if (!uri) { + if (!codebase) { + return PR_FALSE; + } + + nsCOMPtr jarURI; + nsCOMPtr innerUri(codebase); + while((jarURI = do_QueryInterface(innerUri))) { + jarURI->GetJARFile(getter_AddRefs(innerUri)); + } + + if (!innerUri) { return PR_FALSE; } PRBool isHttps = PR_FALSE; - nsresult rv = uri->SchemeIs("https", &isHttps); + nsresult rv = innerUri->SchemeIs("https", &isHttps); return NS_SUCCEEDED(rv) && isHttps; }