|
|
|
Lines 4441-4457
nsContentUtils::CheckSecurityBeforeLoad(
|
Link Here
|
|---|
|
| 4441 |
|
4441 |
|
| 4442 |
// Same Origin |
4442 |
// Same Origin |
| 4443 |
if ((aAllowData && SchemeIs(aURIToLoad, "data")) || |
4443 |
if ((aAllowData && SchemeIs(aURIToLoad, "data")) || |
| 4444 |
((aCheckLoadFlags & nsIScriptSecurityManager::ALLOW_CHROME) && |
4444 |
((aCheckLoadFlags & nsIScriptSecurityManager::ALLOW_CHROME) && |
| 4445 |
SchemeIs(aURIToLoad, "chrome"))) { |
4445 |
SchemeIs(aURIToLoad, "chrome"))) { |
| 4446 |
return NS_OK; |
4446 |
return NS_OK; |
| 4447 |
} |
4447 |
} |
| 4448 |
|
4448 |
|
| 4449 |
return aLoadingPrincipal->CheckMayLoad(aURIToLoad, true); |
4449 |
return aLoadingPrincipal->CheckMayLoad(aURIToLoad, true, false); |
| 4450 |
} |
4450 |
} |
| 4451 |
|
4451 |
|
| 4452 |
bool |
4452 |
bool |
| 4453 |
nsContentUtils::IsSystemPrincipal(nsIPrincipal* aPrincipal) |
4453 |
nsContentUtils::IsSystemPrincipal(nsIPrincipal* aPrincipal) |
| 4454 |
{ |
4454 |
{ |
| 4455 |
bool isSystem; |
4455 |
bool isSystem; |
| 4456 |
nsresult rv = sSecurityManager->IsSystemPrincipal(aPrincipal, &isSystem); |
4456 |
nsresult rv = sSecurityManager->IsSystemPrincipal(aPrincipal, &isSystem); |
| 4457 |
return NS_SUCCEEDED(rv) && isSystem; |
4457 |
return NS_SUCCEEDED(rv) && isSystem; |
|
Lines 5543-5561
nsContentUtils::CheckSameOrigin(nsIChann
|
Link Here
|
|---|
|
| 5543 |
|
5543 |
|
| 5544 |
nsCOMPtr<nsIURI> newURI; |
5544 |
nsCOMPtr<nsIURI> newURI; |
| 5545 |
aNewChannel->GetURI(getter_AddRefs(newURI)); |
5545 |
aNewChannel->GetURI(getter_AddRefs(newURI)); |
| 5546 |
nsCOMPtr<nsIURI> newOriginalURI; |
5546 |
nsCOMPtr<nsIURI> newOriginalURI; |
| 5547 |
aNewChannel->GetOriginalURI(getter_AddRefs(newOriginalURI)); |
5547 |
aNewChannel->GetOriginalURI(getter_AddRefs(newOriginalURI)); |
| 5548 |
|
5548 |
|
| 5549 |
NS_ENSURE_STATE(oldPrincipal && newURI && newOriginalURI); |
5549 |
NS_ENSURE_STATE(oldPrincipal && newURI && newOriginalURI); |
| 5550 |
|
5550 |
|
| 5551 |
nsresult rv = oldPrincipal->CheckMayLoad(newURI, false); |
5551 |
nsresult rv = oldPrincipal->CheckMayLoad(newURI, false, false); |
| 5552 |
if (NS_SUCCEEDED(rv) && newOriginalURI != newURI) { |
5552 |
if (NS_SUCCEEDED(rv) && newOriginalURI != newURI) { |
| 5553 |
rv = oldPrincipal->CheckMayLoad(newOriginalURI, false); |
5553 |
rv = oldPrincipal->CheckMayLoad(newOriginalURI, false, false); |
| 5554 |
} |
5554 |
} |
| 5555 |
|
5555 |
|
| 5556 |
return rv; |
5556 |
return rv; |
| 5557 |
} |
5557 |
} |
| 5558 |
|
5558 |
|
| 5559 |
NS_IMPL_ISUPPORTS2(nsSameOriginChecker, |
5559 |
NS_IMPL_ISUPPORTS2(nsSameOriginChecker, |
| 5560 |
nsIChannelEventSink, |
5560 |
nsIChannelEventSink, |
| 5561 |
nsIInterfaceRequestor) |
5561 |
nsIInterfaceRequestor) |
|
Lines 5722-5738
nsContentUtils::GetDocumentFromScriptCon
|
Link Here
|
|---|
|
| 5722 |
/* static */ |
5722 |
/* static */ |
| 5723 |
bool |
5723 |
bool |
| 5724 |
nsContentUtils::CheckMayLoad(nsIPrincipal* aPrincipal, nsIChannel* aChannel) |
5724 |
nsContentUtils::CheckMayLoad(nsIPrincipal* aPrincipal, nsIChannel* aChannel) |
| 5725 |
{ |
5725 |
{ |
| 5726 |
nsCOMPtr<nsIURI> channelURI; |
5726 |
nsCOMPtr<nsIURI> channelURI; |
| 5727 |
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI)); |
5727 |
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI)); |
| 5728 |
NS_ENSURE_SUCCESS(rv, false); |
5728 |
NS_ENSURE_SUCCESS(rv, false); |
| 5729 |
|
5729 |
|
| 5730 |
return NS_SUCCEEDED(aPrincipal->CheckMayLoad(channelURI, false)); |
5730 |
return NS_SUCCEEDED(aPrincipal->CheckMayLoad(channelURI, false, false)); |
| 5731 |
} |
5731 |
} |
| 5732 |
|
5732 |
|
| 5733 |
nsContentTypeParser::nsContentTypeParser(const nsAString& aString) |
5733 |
nsContentTypeParser::nsContentTypeParser(const nsAString& aString) |
| 5734 |
: mString(aString), mService(nsnull) |
5734 |
: mString(aString), mService(nsnull) |
| 5735 |
{ |
5735 |
{ |
| 5736 |
CallGetService("@mozilla.org/network/mime-hdrparam;1", &mService); |
5736 |
CallGetService("@mozilla.org/network/mime-hdrparam;1", &mService); |
| 5737 |
} |
5737 |
} |
| 5738 |
|
5738 |
|
|
Lines 6471-6487
nsContentUtils::SetUpChannelOwner(nsIPri
|
Link Here
|
|---|
|
| 6471 |
// file: uri special-casing |
6471 |
// file: uri special-casing |
| 6472 |
// |
6472 |
// |
| 6473 |
// If this is a file: load opened from another file: then it may need |
6473 |
// If this is a file: load opened from another file: then it may need |
| 6474 |
// to inherit the owner from the referrer so they can script each other. |
6474 |
// to inherit the owner from the referrer so they can script each other. |
| 6475 |
// If we don't set the owner explicitly then each file: gets an owner |
6475 |
// If we don't set the owner explicitly then each file: gets an owner |
| 6476 |
// based on its own codebase later. |
6476 |
// based on its own codebase later. |
| 6477 |
// |
6477 |
// |
| 6478 |
if (URIIsLocalFile(aURI) && aLoadingPrincipal && |
6478 |
if (URIIsLocalFile(aURI) && aLoadingPrincipal && |
| 6479 |
NS_SUCCEEDED(aLoadingPrincipal->CheckMayLoad(aURI, false)) && |
6479 |
NS_SUCCEEDED(aLoadingPrincipal->CheckMayLoad(aURI, false, false)) && |
| 6480 |
// One more check here. CheckMayLoad will always return true for the |
6480 |
// One more check here. CheckMayLoad will always return true for the |
| 6481 |
// system principal, but we do NOT want to inherit in that case. |
6481 |
// system principal, but we do NOT want to inherit in that case. |
| 6482 |
!IsSystemPrincipal(aLoadingPrincipal)) { |
6482 |
!IsSystemPrincipal(aLoadingPrincipal)) { |
| 6483 |
aChannel->SetOwner(aLoadingPrincipal); |
6483 |
aChannel->SetOwner(aLoadingPrincipal); |
| 6484 |
return true; |
6484 |
return true; |
| 6485 |
} |
6485 |
} |
| 6486 |
|
6486 |
|
| 6487 |
return false; |
6487 |
return false; |