On Wed, Apr 17, 2013 at 5:09 PM, Simon Kornblith <si...@simonster.com>wrote:

> I want to be able to parse XML and expose the resulting document to a
> sandboxed script. I do this by first by determining the principal
> corresponding to a given URI:
>
> var secMan = Services.scriptSecurityManager;
> var uri = Services.io.newURI("http://www.example.com/";, "UTF-8", null);
> var principal = secMan.getCodebasePrincipal(uri);
>
> and then initializing a DOMParser and a sandbox with the resulting
> principal:
>
> var dp = Components.classes["@mozilla.org/xmlextras/domparser;1"]
>  .createInstance(Components.interfaces.nsIDOMParser);
> dp.init(principal, uri, uri);
> var sandbox = new Components.utils.Sandbox(principal);
>
> and finally parsing a document and passing it to a sandboxed function:
>
> var doc = dp.parseFromString('<myxml/>', 'text/xml');
>

Even though doc here comes from a parser, the object itself will still
inherit security characteristics from its scope, unless it explicitly gets
its own Window. So as far as your sandbox is concerned, |doc| is a node
with System Principal, and thus not accessible.

Cheers,
bholley
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to