Skip to content

Commit a608cc2

Browse files
committed
further improvements
(cherry picked from commit fd2016f)
1 parent 948c753 commit a608cc2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tika-core/src/main/java/org/apache/tika/utils/XMLReaderUtils.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import javax.xml.parsers.SAXParser;
3838
import javax.xml.parsers.SAXParserFactory;
3939
import javax.xml.stream.XMLInputFactory;
40-
import javax.xml.stream.XMLResolver;
4140
import javax.xml.transform.Transformer;
4241
import javax.xml.transform.TransformerConfigurationException;
4342
import javax.xml.transform.TransformerFactory;
@@ -124,8 +123,6 @@ public void fatalError(SAXParseException exception) throws SAXException {
124123
private static final AtomicInteger POOL_GENERATION = new AtomicInteger();
125124
private static final EntityResolver IGNORING_SAX_ENTITY_RESOLVER =
126125
(publicId, systemId) -> new InputSource(new StringReader(""));
127-
private static final XMLResolver IGNORING_STAX_ENTITY_RESOLVER =
128-
(publicID, systemID, baseURI, namespace) -> "";
129126
/**
130127
* Parser pool size
131128
*/
@@ -295,7 +292,7 @@ public static DocumentBuilder getDocumentBuilder() throws TikaException {
295292
* If a factory is not explicitly specified, then a default factory
296293
* instance is created and returned. The default factory instance is
297294
* configured to be namespace-aware and to apply reasonable security
298-
* using the {@link #IGNORING_STAX_ENTITY_RESOLVER}.
295+
* precautions.
299296
*
300297
* @return StAX input factory
301298
* @since Apache Tika 1.13
@@ -305,13 +302,12 @@ public static XMLInputFactory getXMLInputFactory() {
305302
if (LOG.isDebugEnabled()) {
306303
LOG.debug("XMLInputFactory class {}", factory.getClass());
307304
}
308-
305+
factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
309306
tryToSetStaxProperty(factory, XMLInputFactory.IS_NAMESPACE_AWARE, true);
310307
tryToSetStaxProperty(factory, XMLInputFactory.IS_VALIDATING, false);
311308
tryToSetStaxProperty(factory, XMLInputFactory.SUPPORT_DTD, false);
312309
tryToSetStaxProperty(factory, XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
313310

314-
factory.setXMLResolver(IGNORING_STAX_ENTITY_RESOLVER);
315311
trySetStaxSecurityManager(factory);
316312
return factory;
317313
}
@@ -1255,7 +1251,7 @@ public static DocumentBuilder getDocumentBuilder(ParseContext context) throws Ti
12551251
* If a factory is not explicitly specified, then a default factory
12561252
* instance is created and returned. The default factory instance is
12571253
* configured to be namespace-aware and to apply reasonable security
1258-
* using the {@link XMLReaderUtils#IGNORING_STAX_ENTITY_RESOLVER}.
1254+
* precautions.
12591255
*
12601256
* @return StAX input factory
12611257
*/

0 commit comments

Comments
 (0)