Part of our java application needs to run javascript that is written by non-developers. These non-developers are using javascript for data formatting. (Simple logic and str
If you are looking for pure JavaScript functions only, here is a solution basing on JDK embedded Rhino library without importing any 3rd-parties libraries:
If given script contains Java script, class loader will try to load JavaMembers or other classes and trigger class not found exceptions. In this way, malicious scripts will be ignored without execution.
Please read ConfigJSParser.java and ConfigJSClassLoader.java files for more details:
https://github.com/webuzz/simpleconfig/tree/master/src/im/webuzz/config