Skip to content

Commit e1cd6fa

Browse files
committed
XMLFactorySAX javaodc #87
1 parent 9fdf796 commit e1cd6fa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

fj-core/src/main/java/org/fugerit/java/core/xml/sax/XMLFactorySAX.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ public static XMLFactorySAX newInstance(boolean validating, boolean namespaceAwa
6262
return newInstance( validating, namespaceAware, Boolean.FALSE );
6363
}
6464

65+
/**
66+
* Creates a new XMLFactorySAX wrapping a javax.xml.parsers.SAXParserFactory
67+
*
68+
* if the secure flag is set, the external entities will be disabled :
69+
*
70+
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
71+
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
72+
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
73+
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
74+
*
75+
* @param validating to set the XMLFactorySAX as validating
76+
* @param namespaceAware to set the XMLFactorySAX as namespaceAware
77+
* @param secure to set the XMLFactorySAX as secure (external entities disabled)
78+
* @return the new configured XMLFactorySAX
79+
* @throws XMLException in case any issue arise
80+
*/
6581
public static XMLFactorySAX newInstance(boolean validating, boolean namespaceAware, boolean secure) throws XMLException {
6682
return XMLException.get( () -> {
6783
SAXParserFactory factory = SAXParserFactory.newInstance();

0 commit comments

Comments
 (0)