From d623c073736a9f9f6bb54b7583e933bf764ec893 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 22 Oct 2013 09:15:46 +0000 Subject: [PATCH] * fix issue with args not being passed in --- source/net/sourceforge/filebot/cli/ScriptShell.java | 5 +++++ .../net/sourceforge/filebot/cli/ScriptShell.lib.groovy | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.java b/source/net/sourceforge/filebot/cli/ScriptShell.java index d47f73d9..77aa83a6 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.java +++ b/source/net/sourceforge/filebot/cli/ScriptShell.java @@ -8,6 +8,7 @@ import java.awt.AWTPermission; import java.io.File; import java.io.FilePermission; import java.io.InputStreamReader; +import java.lang.management.ManagementPermission; import java.lang.reflect.ReflectPermission; import java.net.SocketPermission; import java.net.URI; @@ -170,10 +171,14 @@ class ScriptShell { Permissions permissions = new Permissions(); permissions.add(new RuntimePermission("createClassLoader")); + permissions.add(new RuntimePermission("accessClassInPackage.*")); + permissions.add(new RuntimePermission("modifyThread")); permissions.add(new FilePermission("<>", "read")); permissions.add(new SocketPermission("*", "connect")); permissions.add(new PropertyPermission("*", "read")); permissions.add(new RuntimePermission("getenv.*")); + permissions.add(new RuntimePermission("getFileSystemAttributes")); + permissions.add(new ManagementPermission("monitor")); // write permissions for temp and cache folders permissions.add(new FilePermission(new File(System.getProperty("ehcache.disk.store.dir")).getAbsolutePath() + File.separator + "-", "write, delete")); diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index a889f8b7..b38ec026 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -257,11 +257,12 @@ List.metaClass.sortBySimilarity = { prime, Closure toStringFunction = { obj -> o // call scripts def executeScript(String input, Map bindings = [:], Object... args) { // apply parent script defines - def parameters = new javax.script.SimpleBindings(bindings != null ? _def : [:]) - parameters.putAll(bindings) - + def parameters = new javax.script.SimpleBindings() + // initialize default parameter - parameters['args'] = (args as List).flatten().findResults{ it as File } + parameters.putAll(_def) + parameters.putAll(bindings) + parameters.put('args', args.toList().flatten().findResults{ it as File }) // run given script _shell.runScript(input, parameters)