@@ -33,7 +33,9 @@ Licensed to the Apache Software Foundation (ASF) under one or more
33
33
public class RhinoClassShutter implements ClassShutter {
34
34
public static final List <String > WHITELIST = new ArrayList <>();
35
35
static {
36
- WHITELIST .addAll (Arrays .asList ("java.io.PrintStream" , "java.lang.System" , "java.net.URL" ));
36
+ WHITELIST .addAll (Arrays .asList ("java.io.PrintStream" , "java.lang.System" , "java.net.URL" , ".*Permission" ,
37
+ "org.w3c.dom.*" , "org.apache.batik.w3c.*" , "org.apache.batik.anim.*" , "org.apache.batik.dom.*" ,
38
+ "org.apache.batik.css.*" ));
37
39
}
38
40
39
41
/*
@@ -63,56 +65,11 @@ public void test(String cls) {
63
65
* Returns whether the given class is visible to scripts.
64
66
*/
65
67
public boolean visibleToScripts (String fullClassName ) {
66
- if (!WHITELIST .contains (fullClassName ) && !fullClassName .endsWith ("Permission" ) && !fullClassName .startsWith ("org." )) {
67
- return false ;
68
- }
69
-
70
- // Don't let them mess with script engine's internals.
71
- if (fullClassName .startsWith ("org.mozilla.javascript" ))
72
- return false ;
73
-
74
- if (fullClassName .startsWith ("org.apache.batik." )) {
75
- // Just get package within batik.
76
- String batikPkg = fullClassName .substring (17 );
77
-
78
- // Don't let them mess with Batik script internals.
79
- if (batikPkg .startsWith ("script" ))
80
- return false ;
81
-
82
- // Don't let them get global structures.
83
- if (batikPkg .startsWith ("apps" ))
84
- return false ;
85
-
86
- // Don't let them get scripting stuff from bridge, but specifically
87
- // allow access to:
88
- //
89
- // o.a.b.bridge.ScriptingEnvironment$Window$IntervalScriptTimerTask
90
- // o.a.b.bridge.ScriptingEnvironment$Window$IntervalRunnableTimerTask
91
- // o.a.b.bridge.ScriptingEnvironment$Window$TimeoutScriptTimerTask
92
- // o.a.b.bridge.ScriptingEnvironment$Window$TimeoutRunnableTimerTask
93
- //
94
- // since objects of these classes are returned by setInterval() and
95
- // setTimeout().
96
- if (batikPkg .startsWith ("bridge." )) {
97
- String batikBridgeClass = batikPkg .substring (7 );
98
- if (batikBridgeClass .startsWith ("ScriptingEnvironment" )) {
99
- if (batikBridgeClass .startsWith ("$Window$" , 20 )) {
100
- String c = batikBridgeClass .substring (28 );
101
- if (c .equals ("IntervalScriptTimerTask" )
102
- || c .equals ("IntervalRunnableTimerTask" )
103
- || c .equals ("TimeoutScriptTimerTask" )
104
- || c .equals ("TimeoutRunnableTimerTask" )) {
105
- return true ;
106
- }
107
- }
108
- return false ;
109
- }
110
- if (batikBridgeClass .startsWith ("BaseScriptingEnvironment" )) {
111
- return false ;
112
- }
68
+ for (String v : WHITELIST ) {
69
+ if (fullClassName .matches (v )) {
70
+ return true ;
113
71
}
114
72
}
115
-
116
- return true ;
73
+ return false ;
117
74
}
118
75
}
0 commit comments