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


##########
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:
   Looking at the history class, rejecting documents with a `DOCTYPE` 
declaration was never the intention of Tika maintainers. The setting was 
introduced in #2294 as defense in depth.
   
   `DOCTYPE` declarations are accepted (and external resources ignored) on the 
DOM and SAX paths, so probably StAX should follow the same path.
   
   Keeping `SUPPORT_DTD` at its default `true` also allows every StAX 
implementation to properly **parse** the declaration: Woodstox tokenizes the 
declaration anyway, but the JDK skips **everything** until it encounter the `]` 
character, even if the character is quoted.



-- 
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