зеркало из https://github.com/mozilla/gecko-dev.git
Bug 578182. CSP causing leaks due to repeated AddBoolPrefVarCache call from nsDocument constructor. r=dveditz
This commit is contained in:
Родитель
bd1bb051cf
Коммит
c6eb13a252
|
@ -55,7 +55,7 @@
|
||||||
#include "nsChannelProperties.h"
|
#include "nsChannelProperties.h"
|
||||||
|
|
||||||
/* Keeps track of whether or not CSP is enabled */
|
/* Keeps track of whether or not CSP is enabled */
|
||||||
static PRBool gCSPEnabled = PR_TRUE;
|
PRBool CSPService::sCSPEnabled = PR_TRUE;
|
||||||
|
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
static PRLogModuleInfo* gCspPRLog;
|
static PRLogModuleInfo* gCspPRLog;
|
||||||
|
@ -63,7 +63,7 @@ static PRLogModuleInfo* gCspPRLog;
|
||||||
|
|
||||||
CSPService::CSPService()
|
CSPService::CSPService()
|
||||||
{
|
{
|
||||||
nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled);
|
nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &sCSPEnabled);
|
||||||
|
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
if (!gCspPRLog)
|
if (!gCspPRLog)
|
||||||
|
@ -102,7 +102,7 @@ CSPService::ShouldLoad(PRUint32 aContentType,
|
||||||
*aDecision = nsIContentPolicy::ACCEPT;
|
*aDecision = nsIContentPolicy::ACCEPT;
|
||||||
|
|
||||||
// No need to continue processing if CSP is disabled
|
// No need to continue processing if CSP is disabled
|
||||||
if (!gCSPEnabled)
|
if (!sCSPEnabled)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
// find the principal of the document that initiated this request and see
|
// find the principal of the document that initiated this request and see
|
||||||
|
@ -160,7 +160,7 @@ CSPService::ShouldProcess(PRUint32 aContentType,
|
||||||
*aDecision = nsIContentPolicy::ACCEPT;
|
*aDecision = nsIContentPolicy::ACCEPT;
|
||||||
|
|
||||||
// No need to continue processing if CSP is disabled
|
// No need to continue processing if CSP is disabled
|
||||||
if (!gCSPEnabled)
|
if (!sCSPEnabled)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
// find the nsDocument that initiated this request and see if it has a
|
// find the nsDocument that initiated this request and see if it has a
|
||||||
|
|
|
@ -52,7 +52,8 @@ public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSICONTENTPOLICY
|
NS_DECL_NSICONTENTPOLICY
|
||||||
NS_DECL_NSICHANNELEVENTSINK
|
NS_DECL_NSICHANNELEVENTSINK
|
||||||
|
|
||||||
CSPService();
|
CSPService();
|
||||||
virtual ~CSPService();
|
virtual ~CSPService();
|
||||||
|
static PRBool sCSPEnabled;
|
||||||
};
|
};
|
||||||
|
|
|
@ -195,6 +195,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||||
|
|
||||||
// FOR CSP (autogenerated by xpidl)
|
// FOR CSP (autogenerated by xpidl)
|
||||||
#include "nsIContentSecurityPolicy.h"
|
#include "nsIContentSecurityPolicy.h"
|
||||||
|
#include "nsCSPService.h"
|
||||||
#include "nsHTMLStyleSheet.h"
|
#include "nsHTMLStyleSheet.h"
|
||||||
#include "nsHTMLCSSStyleSheet.h"
|
#include "nsHTMLCSSStyleSheet.h"
|
||||||
|
|
||||||
|
@ -202,9 +203,6 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
|
||||||
/* Keeps track of whether or not CSP is enabled */
|
|
||||||
static PRBool gCSPEnabled = PR_TRUE;
|
|
||||||
|
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
static PRLogModuleInfo* gDocumentLeakPRLog;
|
static PRLogModuleInfo* gDocumentLeakPRLog;
|
||||||
static PRLogModuleInfo* gCspPRLog;
|
static PRLogModuleInfo* gCspPRLog;
|
||||||
|
@ -1409,8 +1407,6 @@ nsDocument::nsDocument(const char* aContentType)
|
||||||
gCspPRLog = PR_NewLogModule("CSP");
|
gCspPRLog = PR_NewLogModule("CSP");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled);
|
|
||||||
|
|
||||||
// Start out mLastStyleSheetSet as null, per spec
|
// Start out mLastStyleSheetSet as null, per spec
|
||||||
SetDOMStringToNull(mLastStyleSheetSet);
|
SetDOMStringToNull(mLastStyleSheetSet);
|
||||||
}
|
}
|
||||||
|
@ -2175,7 +2171,7 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||||
nsresult
|
nsresult
|
||||||
nsDocument::InitCSP()
|
nsDocument::InitCSP()
|
||||||
{
|
{
|
||||||
if (gCSPEnabled) {
|
if (CSPService::sCSPEnabled) {
|
||||||
nsAutoString cspHeaderValue;
|
nsAutoString cspHeaderValue;
|
||||||
nsAutoString cspROHeaderValue;
|
nsAutoString cspROHeaderValue;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче