mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 444641 part 4. Remove the data: special-casing for images in canvas, since we now set the right principal for data: images. r=roc
This commit is contained in:
parent
b84eb03e7e
commit
926cacef5e
@ -68,6 +68,8 @@ DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement,
|
||||
PRBool forceWriteOnly,
|
||||
PRBool CORSUsed)
|
||||
{
|
||||
NS_PRECONDITION(aPrincipal, "Must have a principal here");
|
||||
|
||||
// Callers should ensure that mCanvasElement is non-null before calling this
|
||||
if (!aCanvasElement) {
|
||||
NS_WARNING("DoDrawImageSecurityCheck called without canvas element!");
|
||||
@ -83,9 +85,6 @@ DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement,
|
||||
return;
|
||||
}
|
||||
|
||||
if (aPrincipal == nsnull)
|
||||
return;
|
||||
|
||||
// No need to do a security check if the image used CORS for the load
|
||||
if (CORSUsed)
|
||||
return;
|
||||
|
@ -3604,9 +3604,7 @@ WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
|
||||
|
||||
// part 1: check that the DOM element is same-origin, or has otherwise been
|
||||
// validated for cross-domain use.
|
||||
// if res.mPrincipal == null, no need for the origin check. See DoDrawImageSecurityCheck.
|
||||
// this case happens in the mochitest for images served from mochi.test:8888
|
||||
if (res.mPrincipal && !res.mCORSUsed) {
|
||||
if (!res.mCORSUsed) {
|
||||
PRBool subsumes;
|
||||
nsresult rv = HTMLCanvasElement()->NodePrincipal()->Subsumes(res.mPrincipal, &subsumes);
|
||||
if (NS_FAILED(rv) || !subsumes) {
|
||||
|
@ -4050,27 +4050,10 @@ nsLayoutUtils::SurfaceFromElement(nsIDOMElement *aElement,
|
||||
return result;
|
||||
}
|
||||
|
||||
// In case of data: URIs, we want to ignore principals;
|
||||
// they should have the originating content's principal,
|
||||
// but that's broken at the moment in imgLib.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = imgRequest->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv))
|
||||
return result;
|
||||
|
||||
PRBool isDataURI = PR_FALSE;
|
||||
rv = uri->SchemeIs("data", &isDataURI);
|
||||
if (NS_FAILED(rv))
|
||||
return result;
|
||||
|
||||
// Data URIs are always OK; set the principal
|
||||
// to null to indicate that.
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
if (!isDataURI) {
|
||||
rv = imgRequest->GetImagePrincipal(getter_AddRefs(principal));
|
||||
if (NS_FAILED(rv) || !principal)
|
||||
return result;
|
||||
}
|
||||
rv = imgRequest->GetImagePrincipal(getter_AddRefs(principal));
|
||||
if (NS_FAILED(rv) || !principal)
|
||||
return result;
|
||||
|
||||
nsCOMPtr<imgIContainer> imgContainer;
|
||||
rv = imgRequest->GetImage(getter_AddRefs(imgContainer));
|
||||
|
@ -1357,7 +1357,8 @@ public:
|
||||
nsRefPtr<gfxASurface> mSurface;
|
||||
/* The size of the surface */
|
||||
gfxIntSize mSize;
|
||||
/* The principal associated with the element whose surface was returned */
|
||||
/* The principal associated with the element whose surface was returned.
|
||||
If there is a surface, this will never be null. */
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
/* The image request, if the element is an nsIImageLoadingContent */
|
||||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
|
Loading…
x
Reference in New Issue
Block a user