File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
spring-xml/src/main/java/org/springframework/xml/transform Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 19
19
import javax .xml .transform .TransformerFactory ;
20
20
import javax .xml .transform .TransformerFactoryConfigurationError ;
21
21
22
+ import org .apache .commons .logging .Log ;
23
+ import org .apache .commons .logging .LogFactory ;
24
+
22
25
/**
23
26
* @author Greg Turnquist
24
27
* @since 3.0.5
25
28
*/
26
29
public class TransformerFactoryUtils {
27
30
31
+ private static final Log log = LogFactory .getLog (TransformerFactoryUtils .class );
32
+
28
33
/**
29
34
* Build a new {@link TransformerFactory} using the default constructor.
30
35
*/
@@ -50,8 +55,22 @@ public static TransformerFactory newInstance(Class<? extends TransformerFactory>
50
55
* Prevent external entities from accessing.
51
56
*/
52
57
private static TransformerFactory defaultSettings (TransformerFactory factory ) {
53
- factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
54
- factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_STYLESHEET , "" );
58
+ try {
59
+ factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
60
+ } catch (IllegalArgumentException e ) {
61
+ if (log .isWarnEnabled ()) {
62
+ log .warn (XMLConstants .ACCESS_EXTERNAL_DTD + " property not supported by " + factory .getClass ().getCanonicalName ());
63
+ }
64
+ }
65
+
66
+ try {
67
+ factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_STYLESHEET , "" );
68
+ } catch (IllegalArgumentException e ) {
69
+ if (log .isWarnEnabled ()) {
70
+ log .warn (XMLConstants .ACCESS_EXTERNAL_STYLESHEET + " property not supported by " + factory .getClass ().getCanonicalName ());
71
+ }
72
+ }
73
+
55
74
return factory ;
56
75
}
57
76
}
You can’t perform that action at this time.
0 commit comments