diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index ceccacf1c78..34a8abcefb1 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -56,6 +56,8 @@ #include "nsIServiceManager.h" #include "nsBoxLayoutState.h" #include "nsIBox.h" +#include "nsIDOMElement.h" +#include "nsContentPolicyUtils.h" #ifdef _WIN32 #include @@ -906,6 +908,21 @@ nsPresContext::StartLoadImage(const nsString& aURL, return NS_OK; } } + + // Check with the content-policy things to make sure this load is permitted. + PRBool shouldLoad = PR_TRUE; // default permit + nsCOMPtr content; + nsCOMPtr element; + if (aTargetFrame && + NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) { + element = do_QueryInterface(content); + } + + if (NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::CONTENT_IMAGE, + aURL, element, &shouldLoad)) + && !shouldLoad) { + return NS_OK; + } // Create image group if needed nsresult rv; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index ceccacf1c78..34a8abcefb1 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -56,6 +56,8 @@ #include "nsIServiceManager.h" #include "nsBoxLayoutState.h" #include "nsIBox.h" +#include "nsIDOMElement.h" +#include "nsContentPolicyUtils.h" #ifdef _WIN32 #include @@ -906,6 +908,21 @@ nsPresContext::StartLoadImage(const nsString& aURL, return NS_OK; } } + + // Check with the content-policy things to make sure this load is permitted. + PRBool shouldLoad = PR_TRUE; // default permit + nsCOMPtr content; + nsCOMPtr element; + if (aTargetFrame && + NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) { + element = do_QueryInterface(content); + } + + if (NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::CONTENT_IMAGE, + aURL, element, &shouldLoad)) + && !shouldLoad) { + return NS_OK; + } // Create image group if needed nsresult rv;