|
|
|
Lines 174-198
static NS_DEFINE_CID(kDOMEventGroupCID,
|
Link Here
|
|---|
|
| 174 |
#include "mozAutoDocUpdate.h" |
174 |
#include "mozAutoDocUpdate.h" |
| 175 |
|
175 |
|
| 176 |
#ifdef MOZ_SMIL |
176 |
#ifdef MOZ_SMIL |
| 177 |
#include "nsSMILAnimationController.h" |
177 |
#include "nsSMILAnimationController.h" |
| 178 |
#include "imgIContainer.h" |
178 |
#include "imgIContainer.h" |
| 179 |
#include "nsSVGUtils.h" |
179 |
#include "nsSVGUtils.h" |
| 180 |
#endif // MOZ_SMIL |
180 |
#endif // MOZ_SMIL |
| 181 |
|
181 |
|
|
|
182 |
// FOR CSP (autogenerated by xpidl) |
| 183 |
#include "IContentSecurityPolicy.h" |
| 184 |
|
| 182 |
|
185 |
|
| 183 |
#ifdef MOZ_LOGGING |
186 |
#ifdef MOZ_LOGGING |
| 184 |
// so we can get logging even in release builds |
187 |
// so we can get logging even in release builds |
| 185 |
#define FORCE_PR_LOG 1 |
188 |
#define FORCE_PR_LOG 1 |
| 186 |
#endif |
189 |
#endif |
| 187 |
#include "prlog.h" |
190 |
#include "prlog.h" |
| 188 |
|
191 |
|
| 189 |
#ifdef PR_LOGGING |
192 |
#ifdef PR_LOGGING |
| 190 |
static PRLogModuleInfo* gDocumentLeakPRLog; |
193 |
static PRLogModuleInfo* gDocumentLeakPRLog; |
|
|
194 |
static PRLogModuleInfo* gCspPRLog; |
| 191 |
#endif |
195 |
#endif |
| 192 |
|
196 |
|
| 193 |
void |
197 |
void |
| 194 |
nsUint32ToContentHashEntry::Destroy() |
198 |
nsUint32ToContentHashEntry::Destroy() |
| 195 |
{ |
199 |
{ |
| 196 |
HashSet* set = GetHashSet(); |
200 |
HashSet* set = GetHashSet(); |
| 197 |
if (set) { |
201 |
if (set) { |
| 198 |
delete set; |
202 |
delete set; |
|
Lines 1473-1488
nsDocument::nsDocument(const char* aCont
|
Link Here
|
|---|
|
| 1473 |
|
1477 |
|
| 1474 |
#ifdef PR_LOGGING |
1478 |
#ifdef PR_LOGGING |
| 1475 |
if (!gDocumentLeakPRLog) |
1479 |
if (!gDocumentLeakPRLog) |
| 1476 |
gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak"); |
1480 |
gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak"); |
| 1477 |
|
1481 |
|
| 1478 |
if (gDocumentLeakPRLog) |
1482 |
if (gDocumentLeakPRLog) |
| 1479 |
PR_LOG(gDocumentLeakPRLog, PR_LOG_DEBUG, |
1483 |
PR_LOG(gDocumentLeakPRLog, PR_LOG_DEBUG, |
| 1480 |
("DOCUMENT %p created", this)); |
1484 |
("DOCUMENT %p created", this)); |
|
|
1485 |
|
| 1486 |
if (!gCspPRLog) |
| 1487 |
gCspPRLog = PR_NewLogModule("CSP"); |
| 1488 |
|
| 1481 |
#endif |
1489 |
#endif |
| 1482 |
|
1490 |
|
| 1483 |
// Start out mLastStyleSheetSet as null, per spec |
1491 |
// Start out mLastStyleSheetSet as null, per spec |
| 1484 |
SetDOMStringToNull(mLastStyleSheetSet); |
1492 |
SetDOMStringToNull(mLastStyleSheetSet); |
| 1485 |
} |
1493 |
} |
| 1486 |
|
1494 |
|
| 1487 |
static PLDHashOperator |
1495 |
static PLDHashOperator |
| 1488 |
ClearAllBoxObjects(const void* aKey, nsPIBoxObject* aBoxObject, void* aUserArg) |
1496 |
ClearAllBoxObjects(const void* aKey, nsPIBoxObject* aBoxObject, void* aUserArg) |
|
Lines 2230-2245
nsDocument::StartDocumentLoad(const char
|
Link Here
|
|---|
|
| 2230 |
semicolon = start; |
2238 |
semicolon = start; |
| 2231 |
FindCharInReadable(';', semicolon, end); |
2239 |
FindCharInReadable(';', semicolon, end); |
| 2232 |
mContentType = Substring(start, semicolon); |
2240 |
mContentType = Substring(start, semicolon); |
| 2233 |
} |
2241 |
} |
| 2234 |
|
2242 |
|
| 2235 |
RetrieveRelevantHeaders(aChannel); |
2243 |
RetrieveRelevantHeaders(aChannel); |
| 2236 |
|
2244 |
|
| 2237 |
mChannel = aChannel; |
2245 |
mChannel = aChannel; |
|
|
2246 |
|
| 2247 |
// -------------- Initialize CSP |
| 2248 |
|
| 2249 |
PRBool cspEnabled; |
| 2250 |
cspEnabled = nsContentUtils::GetBoolPref("security.csp.enable", PR_FALSE); |
| 2251 |
|
| 2252 |
if (cspEnabled) |
| 2253 |
{ |
| 2254 |
nsresult rv; |
| 2255 |
PRBool system; |
| 2256 |
nsIScriptSecurityManager *ssm = nsContentUtils::GetSecurityManager(); |
| 2257 |
nsAutoString cspHeaderValue; |
| 2258 |
nsAutoString cspROHeaderValue; |
| 2259 |
nsIAtom* cspHeaderAtom = NS_NewAtom("x-content-security-policy"); |
| 2260 |
nsIAtom* cspROHeaderAtom = NS_NewAtom("x-content-security-policy-report-only"); |
| 2261 |
|
| 2262 |
this->GetHeaderData(cspHeaderAtom, cspHeaderValue); |
| 2263 |
this->GetHeaderData(cspROHeaderAtom, cspROHeaderValue); |
| 2264 |
|
| 2265 |
if(NS_SUCCEEDED(ssm->IsSystemPrincipal(NodePrincipal(), &system)) && system) { |
| 2266 |
//only makes sense to register new CSP if this document is not priviliged |
| 2267 |
return NS_OK; |
| 2268 |
} |
| 2269 |
|
| 2270 |
if(cspHeaderValue.IsEmpty() && cspROHeaderValue.IsEmpty()) { |
| 2271 |
// no CSP header present |
| 2272 |
return NS_OK; |
| 2273 |
} |
| 2274 |
|
| 2275 |
#ifdef PR_LOGGING |
| 2276 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, |
| 2277 |
("CSP header specified for document %p", this)); |
| 2278 |
#endif |
| 2279 |
|
| 2280 |
nsCOMPtr<IContentSecurityPolicy> mCSP; |
| 2281 |
mCSP = do_CreateInstance("@mozilla.org/contentsecuritypolicy;1", &rv); |
| 2282 |
|
| 2283 |
if(NS_FAILED(rv)) { |
| 2284 |
#ifdef PR_LOGGING |
| 2285 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("Failed to create CSP object: %6x", rv)); |
| 2286 |
#endif |
| 2287 |
return rv; |
| 2288 |
} |
| 2289 |
|
| 2290 |
// Store the request context for violation reports |
| 2291 |
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel); |
| 2292 |
mCSP->ScanRequestData(httpChannel); |
| 2293 |
|
| 2294 |
// Start parsing the policy |
| 2295 |
nsCOMPtr<nsIURI> chanURI; |
| 2296 |
aChannel->GetURI(getter_AddRefs(chanURI)); |
| 2297 |
|
| 2298 |
#ifdef PR_LOGGING |
| 2299 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("CSP Loaded")); |
| 2300 |
#endif |
| 2301 |
|
| 2302 |
// ReportOnly mode is enabled *only* if there are no regular-strength CSP |
| 2303 |
// headers present. If there are, then we ignore the ReportOnly mode and |
| 2304 |
// toss a warning into the error console, proceeding with enforcing the |
| 2305 |
// regular-strength CSP. |
| 2306 |
if(cspHeaderValue.IsEmpty()) { |
| 2307 |
mCSP->SetReportOnlyMode(true); |
| 2308 |
mCSP->RefinePolicy(cspROHeaderValue, chanURI); |
| 2309 |
#ifdef PR_LOGGING |
| 2310 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, |
| 2311 |
("CSP (report only) refined, policy: \"%s\"", |
| 2312 |
ToNewCString(cspROHeaderValue))); |
| 2313 |
#endif |
| 2314 |
|
| 2315 |
} else { |
| 2316 |
//if(!cspROHeaderValue.IsEmpty()) { |
| 2317 |
//TODO: post warning that both read only and regular CSP headers are |
| 2318 |
//present. |
| 2319 |
//} |
| 2320 |
mCSP->RefinePolicy(cspHeaderValue, chanURI); |
| 2321 |
#ifdef PR_LOGGING |
| 2322 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, |
| 2323 |
("CSP refined, policy: \"%s\"", ToNewCString(cspHeaderValue))); |
| 2324 |
#endif |
| 2325 |
} |
| 2326 |
|
| 2327 |
//Copy into principal |
| 2328 |
nsIPrincipal* principal = GetPrincipal(); |
| 2329 |
|
| 2330 |
if (principal) { |
| 2331 |
principal->SetCsp(mCSP); |
| 2332 |
#ifdef PR_LOGGING |
| 2333 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, |
| 2334 |
("Inserted CSP into principal %p", principal)); |
| 2335 |
} |
| 2336 |
else { |
| 2337 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, |
| 2338 |
("Couldn't copy CSP into absent principal %p", principal)); |
| 2339 |
#endif |
| 2340 |
} |
| 2341 |
} |
| 2342 |
#ifdef PR_LOGGING |
| 2343 |
else //CSP was not enabled! |
| 2344 |
PR_LOG(gCspPRLog, PR_LOG_DEBUG, |
| 2345 |
("CSP is disabled, skipping CSP init for document %p", this)); |
| 2346 |
#endif |
| 2347 |
|
| 2348 |
// -------------- CSP initialized |
| 2238 |
|
2349 |
|
| 2239 |
return NS_OK; |
2350 |
return NS_OK; |
| 2240 |
} |
2351 |
} |
| 2241 |
|
2352 |
|
| 2242 |
void |
2353 |
void |
| 2243 |
nsDocument::StopDocumentLoad() |
2354 |
nsDocument::StopDocumentLoad() |
| 2244 |
{ |
2355 |
{ |
| 2245 |
if (mParser) { |
2356 |
if (mParser) { |
|
Lines 6606-6621
nsDocument::RetrieveRelevantHeaders(nsIC
|
Link Here
|
|---|
|
| 6606 |
|
6717 |
|
| 6607 |
static const char *const headers[] = { |
6718 |
static const char *const headers[] = { |
| 6608 |
"default-style", |
6719 |
"default-style", |
| 6609 |
"content-style-type", |
6720 |
"content-style-type", |
| 6610 |
"content-language", |
6721 |
"content-language", |
| 6611 |
"content-disposition", |
6722 |
"content-disposition", |
| 6612 |
"refresh", |
6723 |
"refresh", |
| 6613 |
"x-dns-prefetch-control", |
6724 |
"x-dns-prefetch-control", |
|
|
6725 |
"x-content-security-policy", |
| 6726 |
"x-content-security-policy-read-only", |
| 6614 |
// add more http headers if you need |
6727 |
// add more http headers if you need |
| 6615 |
// XXXbz don't add content-location support without reading bug |
6728 |
// XXXbz don't add content-location support without reading bug |
| 6616 |
// 238654 and its dependencies/dups first. |
6729 |
// 238654 and its dependencies/dups first. |
| 6617 |
0 |
6730 |
0 |
| 6618 |
}; |
6731 |
}; |
| 6619 |
|
6732 |
|
| 6620 |
nsCAutoString headerVal; |
6733 |
nsCAutoString headerVal; |
| 6621 |
const char *const *name = headers; |
6734 |
const char *const *name = headers; |
|
Lines 6909-6924
nsDocument::CanSavePresentation(nsIReque
|
Link Here
|
|---|
|
| 6909 |
|
7022 |
|
| 6910 |
void |
7023 |
void |
| 6911 |
nsDocument::Destroy() |
7024 |
nsDocument::Destroy() |
| 6912 |
{ |
7025 |
{ |
| 6913 |
// The ContentViewer wants to release the document now. So, tell our content |
7026 |
// The ContentViewer wants to release the document now. So, tell our content |
| 6914 |
// to drop any references to the document so that it can be destroyed. |
7027 |
// to drop any references to the document so that it can be destroyed. |
| 6915 |
if (mIsGoingAway) |
7028 |
if (mIsGoingAway) |
| 6916 |
return; |
7029 |
return; |
|
|
7030 |
|
| 7031 |
//XXX: if there's any cleanup for CSP, do it here. |
| 6917 |
|
7032 |
|
| 6918 |
mIsGoingAway = PR_TRUE; |
7033 |
mIsGoingAway = PR_TRUE; |
| 6919 |
|
7034 |
|
| 6920 |
RemovedFromDocShell(); |
7035 |
RemovedFromDocShell(); |
| 6921 |
|
7036 |
|
| 6922 |
PRUint32 i, count = mChildren.ChildCount(); |
7037 |
PRUint32 i, count = mChildren.ChildCount(); |
| 6923 |
for (i = 0; i < count; ++i) { |
7038 |
for (i = 0; i < count; ++i) { |
| 6924 |
mChildren.ChildAt(i)->DestroyContent(); |
7039 |
mChildren.ChildAt(i)->DestroyContent(); |