From ff951383c36afc519c33a7c61de1f345c33a1ddc Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Fri, 10 Nov 2006 23:45:05 +0000 Subject: [PATCH] Load images into our own security domain so that we can examine their pixels. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4449 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/MediaContainer.as | 32 ++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/as/com/threerings/util/MediaContainer.as b/src/as/com/threerings/util/MediaContainer.as index 2e31bf961..dbdd0caf0 100644 --- a/src/as/com/threerings/util/MediaContainer.as +++ b/src/as/com/threerings/util/MediaContainer.as @@ -317,13 +317,33 @@ public class MediaContainer extends Box */ protected function getContext (url :String) :LoaderContext { -// // We allow content to share but not overwrite our classes -// return new LoaderContext(true, -// new ApplicationDomain(ApplicationDomain.currentDomain), -// SecurityDomain.currentDomain); + if (isImage(url)) { + // load images into our domain so that we can view their pixels + return new LoaderContext(true, + new ApplicationDomain(ApplicationDomain.currentDomain), + SecurityDomain.currentDomain); - // share nothing, trust nothing - return new LoaderContext(false, null, null); + } else { + // share nothing, trust nothing + return new LoaderContext(false, null, null); + } + } + + /** + * Does the specified url represent an image? + */ + protected function isImage (url :String) :Boolean + { + // look at the last 4 characters in the lowercased url + switch (url.toLowerCase().slice(-4)) { + case ".png": + case ".jpg": + case ".gif": + return true; + + default: + return false; + } } /**