Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand All @@ -38,6 +39,26 @@
public class DbFactory {
public static DocumentBuilder getInstance() throws ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
String FEATURE = null;
try {
FEATURE = "http://xml.org/sax/features/external-parameter-entities";
factory.setFeature(FEATURE, false);

FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
factory.setFeature(FEATURE, false);

FEATURE = "http://xml.org/sax/features/external-general-entities";
factory.setFeature(FEATURE, false);

factory.setXIncludeAware(false);
factory.setExpandEntityReferences(false);

factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

} catch (ParserConfigurationException e) {
throw new IllegalStateException("The feature '"
+ FEATURE + "' is not supported by your XML processor.", e);
}
factory.setNamespaceAware(true);
factory.setValidating(false);
factory.setIgnoringComments(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.Map;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -139,6 +140,26 @@ public LayoutDefinition read() throws IOException {
try {
// Get a DocumentBuilderFactory and set it up
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
String FEATURE = null;
try {
FEATURE = "http://xml.org/sax/features/external-parameter-entities";
dbf.setFeature(FEATURE, false);

FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
dbf.setFeature(FEATURE, false);

FEATURE = "http://xml.org/sax/features/external-general-entities";
dbf.setFeature(FEATURE, false);

dbf.setXIncludeAware(false);
dbf.setExpandEntityReferences(false);

dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

} catch (ParserConfigurationException e) {
throw new IllegalStateException("The feature '"
+ FEATURE + "' is not supported by your XML processor.", e);
}
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setIgnoringComments(true);
Expand Down