ppkarwasz commented on code in PR #3261:
URL: https://github.com/apache/tika/pull/3261#discussion_r4115221029


##########
tika-core/src/main/java/org/apache/tika/utils/XMLReaderUtils.java:
##########
@@ -304,66 +285,22 @@ public static DocumentBuilder getDocumentBuilder() throws 
TikaException {
      * @since Apache Tika 1.13
      */
     public static XMLInputFactory getXMLInputFactory() {
-        XMLInputFactory factory = XMLInputFactory.newFactory();
+        XMLInputFactory factory = SecureXMLInputFactory.newFactory();
         if (LOG.isDebugEnabled()) {
             LOG.debug("XMLInputFactory class {}", factory.getClass());
         }
 
         tryToSetStaxProperty(factory, XMLInputFactory.IS_NAMESPACE_AWARE, 
true);
 
         //try to configure secure processing
-        tryToSetStaxProperty(factory, XMLConstants.ACCESS_EXTERNAL_DTD, "");
         tryToSetStaxProperty(factory, XMLInputFactory.IS_VALIDATING, false);
         tryToSetStaxProperty(factory, XMLInputFactory.SUPPORT_DTD, false);
         tryToSetStaxProperty(factory, 
XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
 
-        //defense in depth
-        factory.setXMLResolver(IGNORING_STAX_ENTITY_RESOLVER);

Review Comment:
   All the `tryToSetStaxProperty` calls can also be removed:
   
   - `IS_NAMESPACE_AWARE` is `true` by default (mandated by the StAX 
specification),
   - `IS_VALIDATING` is `false` by default,
   - `SUPPORT_DTD` and `IS_SUPPORTING_EXTERNAL_ENTITIES` would be 
“defense-in-depth”: they disable DTD **before** it is passed on to the resolver.
   - The resolver was removed, because Commons Secure XML installs its own.
   - `ACCESS_EXTERNAL_DTD` will never be triggered, because resources opted-in 
by a resolver are not checked against this property. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to