safer retrieval of groovy scripts from URLs
authorjprocter <Jim Procter>
Mon, 30 Jun 2008 09:49:44 +0000 (09:49 +0000)
committerjprocter <Jim Procter>
Mon, 30 Jun 2008 09:49:44 +0000 (09:49 +0000)
src/jalview/bin/Jalview.java

index faf98db..4f383a0 100755 (executable)
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.lang.reflect.Constructor;
+import java.net.URL;
 import java.util.*;
 
 import javax.swing.*;
@@ -466,10 +467,10 @@ public class Jalview
         java.lang.reflect.Method setvar = gbindingc.getMethod("setVariable", new Class[] { String.class, Object.class} );
         setvar.invoke(gbinding, new Object[] { "Jalview", jalviewContext});
         Class gsec = cl.loadClass("groovy.util.GroovyScriptEngine");
-        Constructor gseccons = gsec.getConstructor(new Class[] { String[].class });
-        Object gse = gseccons.newInstance(new Object[] { new String[] { sfile.toURL().toString() } });
+        Constructor gseccons = gsec.getConstructor(new Class[] { URL[].class } ); // String[].class });
+        Object gse = gseccons.newInstance(new Object[] { new URL[] { sfile.toURL() } }); // .toString() } });
         java.lang.reflect.Method run = gsec.getMethod("run", new Class[]{ String.class, gbindingc });
-        run.invoke(gse, new Object[] { sfile.toURL().toString(), gbinding });
+        run.invoke(gse, new Object[] { sfile.getName(), gbinding });
         success = true;
     } catch (Exception e)
     {