Skip to content

Commit

Permalink
fix user option form XML_DOCTYPE, apache#2744
Browse files Browse the repository at this point in the history
  • Loading branch information
hansva committed Nov 12, 2024
1 parent 03f92b5 commit cd446e5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.apache.hop.core.Const;
import org.apache.hop.core.util.EnvUtil;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;

Expand All @@ -37,13 +38,14 @@ private XmlParserFactoryProducer() {
*
* @throws ParserConfigurationException if feature can't be enabled
*/
@SuppressWarnings("java:S2755")
public static DocumentBuilderFactory createSecureDocBuilderFactory()
throws ParserConfigurationException {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
docBuilderFactory.setFeature(
"http://apache.org/xml/features/disallow-doctype-decl",
"N".equals(Const.XML_ALLOW_DOCTYPE_DECL));
"N".equals(EnvUtil.getSystemProperty(Const.XML_ALLOW_DOCTYPE_DECL)));

return docBuilderFactory;
}
Expand Down

0 comments on commit cd446e5

Please sign in to comment.