diff options
| author | jmoenig <jens@moenig.org> | 2013-09-18 15:34:59 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-09-18 15:34:59 +0200 |
| commit | e9afcc9ec3e990eb1ebc79790fcf5048372858c1 (patch) | |
| tree | d1dbf920aa3b93174adb70e9d57cf60d9c01ad98 /objects.js | |
| parent | c0a0c1f4a7a9f3cfd055288817530cf7c46bb26d (diff) | |
| download | snap-byow-e9afcc9ec3e990eb1ebc79790fcf5048372858c1.tar.gz snap-byow-e9afcc9ec3e990eb1ebc79790fcf5048372858c1.zip | |
prevent costumes with imported CORS-tainted canvases
expected to fix #155, #154, #151, #148, #147, #127 for future projects
Diffstat (limited to 'objects.js')
| -rw-r--r-- | objects.js | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2013-September-17'; +modules.objects = '2013-September-18'; var SpriteMorph; var StageMorph; @@ -5246,6 +5246,24 @@ Costume.prototype.thumbnail = function (extentPoint) { return trg; }; +// Costume catching "tainted" canvases + +Costume.prototype.isTainted = function () { + // find out whether the canvas has been tainted by cross-origin data + // assumes that if reading image data throws an error it is tainted + try { + this.contents.getContext('2d').getImageData( + 0, + 0, + this.contents.width, + this.contents.height + ); + } catch (err) { + return true; + } + return false; +}; + // SVG_Costume ///////////////////////////////////////////////////////////// /* |
