summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2019-08-22 21:57:50 +0000
committerPJ Fanning <fanningpj@apache.org>2019-08-22 21:57:50 +0000
commit3623bea5058cb642888a7199e5ceaecdac4c0a62 (patch)
tree46ff1a900978c9fa591b51762f88b6ee9a2f6c7d
parenta3298f9c1644baeb9e9d551974492d33112918d3 (diff)
downloadpoi-3623bea5058cb642888a7199e5ceaecdac4c0a62.tar.gz
poi-3623bea5058cb642888a7199e5ceaecdac4c0a62.zip
[bug-63664] do not use DocumentBuilderFactory directly
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1865720 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/ooxml/dev/OOXMLPrettyPrint.java7
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/converter/WordToTextConverter.java3
2 files changed, 4 insertions, 6 deletions
diff --git a/src/ooxml/java/org/apache/poi/ooxml/dev/OOXMLPrettyPrint.java b/src/ooxml/java/org/apache/poi/ooxml/dev/OOXMLPrettyPrint.java
index e48f65ffb9..6cf5eb2cfb 100644
--- a/src/ooxml/java/org/apache/poi/ooxml/dev/OOXMLPrettyPrint.java
+++ b/src/ooxml/java/org/apache/poi/ooxml/dev/OOXMLPrettyPrint.java
@@ -27,7 +27,6 @@ import java.util.zip.ZipException;
import java.util.zip.ZipOutputStream;
import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
@@ -39,6 +38,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.poi.ooxml.util.DocumentHelper;
import org.apache.poi.openxml4j.opc.internal.ZipHelper;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.util.IOUtils;
@@ -53,14 +53,13 @@ import org.xml.sax.InputSource;
* use different formatting of the XML.
*/
public class OOXMLPrettyPrint {
- private final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
private final DocumentBuilder documentBuilder;
- public OOXMLPrettyPrint() throws ParserConfigurationException {
+ public OOXMLPrettyPrint() {
// allow files with much lower inflation rate here as there is no risk of Zip Bomb attacks in this developer tool
ZipSecureFile.setMinInflateRatio(0.00001);
- documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ documentBuilder = DocumentHelper.newDocumentBuilder();
}
public static void main(String[] args) throws Exception {
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToTextConverter.java b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToTextConverter.java
index b469df3031..399029233d 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToTextConverter.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToTextConverter.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
@@ -142,7 +141,7 @@ public class WordToTextConverter extends AbstractWordConverter
public WordToTextConverter() throws ParserConfigurationException
{
this.textDocumentFacade = new TextDocumentFacade(
- DocumentBuilderFactory.newInstance().newDocumentBuilder()
+ XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
.newDocument() );
}