Hi,
> What do you suggest? Allow file access by default?
for Freeplane I found a better solution, but I am afraid it can not work
for FreeMind. I changed ScriptingEngine.java as follows (see below) and
removed root directory "." from the class path. I attach my current
version of ScriptingEngine.java to the mail too.
Regards,
Dimitry
> ===================================================================
> --- freeplane_program/trunk/freeplane_plugin_script/src/org/freeplane/plugin/script/ScriptingEngine.java 2009-05-10 18:19:16 UTC (rev 362)
> +++ freeplane_program/trunk/freeplane_plugin_script/src/org/freeplane/plugin/script/ScriptingEngine.java 2009-05-11 21:50:05 UTC (rev 363)
> @@ -21,8 +21,10 @@
> import groovy.lang.Binding;
> import groovy.lang.GroovyRuntimeException;
> import groovy.lang.GroovyShell;
> +import groovy.lang.Script;
>
> import java.awt.event.ActionEvent;
> +import java.io.InputStream;
> import java.io.PrintStream;
> import java.util.HashMap;
> import java.util.Iterator;
> @@ -32,6 +34,8 @@
>
> import org.codehaus.groovy.ast.ASTNode;
> import org.codehaus.groovy.ast.ModuleNode;
> +import org.codehaus.groovy.control.CompilationFailedException;
> +import org.codehaus.groovy.runtime.InvokerHelper;
> import org.freeplane.core.controller.Controller;
> import org.freeplane.core.model.NodeModel;
> import org.freeplane.core.resources.ResourceBundles;
> @@ -94,7 +98,6 @@
> binding.setVariable("c", pMindMapController);
> binding.setVariable("node", node);
> binding.setVariable("cookies", ScriptingEngine.sScriptCookies);
> - final GroovyShell shell = new GroovyShell(binding);
> boolean assignResult = false;
> String assignTo = null;
> if (script.startsWith("=")) {
> @@ -149,7 +152,27 @@
> final FreeplaneSecurityManager securityManager = (FreeplaneSecurityManager) System.getSecurityManager();
> try {
> System.setOut(pOutStream);
> - securityManager.setFinalSecurityManager(scriptingSecurityManager);
> + final GroovyShell shell = new GroovyShell(binding){
> + /**
> + * Evaluates some script against the current Binding and returns the result
> + *
> + * @param in the stream reading the script
> + * @param fileName is the logical file name of the script (which is used to create the class name of the script)
> + */
> + public Object evaluate(InputStream in, String fileName) throws CompilationFailedException {
> + Script script = null;
> + try {
> + script = parse(in, fileName);
> + securityManager.setFinalSecurityManager(scriptingSecurityManager);
> + return script.run();
> + } finally {
> + if (script != null) {
> + InvokerHelper.removeClass(script.getClass());
> + }
> + }
> + }
> +
> + };
> value = shell.evaluate(script);
> }
> catch (final GroovyRuntimeException e) {
>
|