This commit is contained in:
jstaerk
2025-03-12 13:43:12 +01:00
parent c3332c3329
commit 2bcedad471
4 changed files with 17 additions and 0 deletions

View File

@@ -61,6 +61,10 @@ public abstract class Validator {
Source xmlData = new StreamSource(new ByteArrayInputStream(xmlRawData));
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
schemaFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
schemaFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
schemaFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
Schema schema = schemaFactory.newSchema(schemaFile);
javax.xml.validation.Validator validator = schema.newValidator();
validator.validate(xmlData);