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 1919import javax .xml .transform .TransformerFactory ;
2020import javax .xml .transform .TransformerFactoryConfigurationError ;
2121
22+ import org .apache .commons .logging .Log ;
23+ import org .apache .commons .logging .LogFactory ;
24+
2225/**
2326 * @author Greg Turnquist
2427 * @since 3.0.5
2528 */
2629public class TransformerFactoryUtils {
2730
31+ private static final Log log = LogFactory .getLog (TransformerFactoryUtils .class );
32+
2833 /**
2934 * Build a new {@link TransformerFactory} using the default constructor.
3035 */
@@ -50,8 +55,22 @@ public static TransformerFactory newInstance(Class<? extends TransformerFactory>
5055 * Prevent external entities from accessing.
5156 */
5257 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+
5574 return factory ;
5675 }
5776}
You can’t perform that action at this time.
0 commit comments