开发者

What is the origin security for in a canvas?

开发者 https://www.devze.com 2023-03-12 10:47 出处:网络
I just read that if you load an image served from a different origin in a canvas you can see it but if you try, for instance, to access the imageData of that image, it is raising a SECURITY_EXCEPTION.

I just read that if you load an image served from a different origin in a canvas you can see it but if you try, for instance, to access the imageData of that image, it is raising a SECURITY_EXCEPTION.

I get that,开发者_开发技巧 I just having hard times finding the reason for that. Do you guys have some example on why there is such a restriction like this one?


Imagine you have uploaded some personal photos to a private photo storage service - now imagine that private photo storage service has adverts that use the canvas element. If there's no origin restriction and I want to steal all your private photos, all I need to do is buy advertising space on the site, then use drawImage() to grab your photo then send the results of toDataURL() back in an AJAX request.

0

精彩评论

暂无评论...
验证码 换一张
取 消