Freedom for javascript mods (#5421)
* remove blacklist and class shutter * no context factory
This commit is contained in:
@@ -752,8 +752,8 @@ public class ContentParser{
|
||||
var out = ClassMap.classes.get(!base.isEmpty() && Character.isLowerCase(base.charAt(0)) ? Strings.capitalize(base) : base);
|
||||
if(out != null) return (Class<T>)out;
|
||||
|
||||
//try to resolve it as a raw class name if it's allowed
|
||||
if(base.indexOf('.') != -1 && Scripts.allowClass(base)){
|
||||
//try to resolve it as a raw class name
|
||||
if(base.indexOf('.') != -1){
|
||||
try{
|
||||
return (Class<T>)Class.forName(base);
|
||||
}catch(Exception ignored){
|
||||
|
||||
@@ -22,22 +22,12 @@ import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Scripts implements Disposable{
|
||||
private static final Seq<String> blacklist = Seq.with(".net.", "java.net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk",
|
||||
"runtime", "util.os", "rmi", "security", "org.", "sun.", "beans", "sql", "http", "exec", "compiler", "process", "system",
|
||||
".awt", "socket", "classloader", "oracle", "invoke", "java.util.function", "java.util.stream", "org.", "mod.classmap");
|
||||
private static final Seq<String> whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "jdk.proxy", "mindustry.gen.",
|
||||
"mindustry.logic.", "mindustry.async.", "saveio", "systemcursor", "filetreeinitevent", "asyncexecutor");
|
||||
|
||||
private final Context context;
|
||||
private final Scriptable scope;
|
||||
private boolean errored;
|
||||
|
||||
LoadedMod currentMod = null;
|
||||
|
||||
public static boolean allowClass(String type){
|
||||
return !blacklist.contains(t -> type.toLowerCase(Locale.ROOT).contains(t)) || whitelist.contains(t -> type.toLowerCase(Locale.ROOT).contains(t));
|
||||
}
|
||||
|
||||
public Scripts(){
|
||||
Time.mark();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user