Skip to content

Commit

Permalink
Secure XML parser some more
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Jan 11, 2024
1 parent 1e23313 commit e50f396
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Element;

import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.InputStream;
Expand Down Expand Up @@ -105,6 +106,8 @@ public XMLBoundProperties getPropertyFinder(Class<?> clazz) {
public GuiComponent load(Object bindTo, InputStream stream) {
var factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
var builder = factory.newDocumentBuilder();
var document = builder.parse(stream);
Element documentElement = document.getDocumentElement();
Expand Down

0 comments on commit e50f396

Please sign in to comment.