Skip to content

Commit cd52ffe

Browse files
committed
Fixing SAXParserFactory init (#1284)
1 parent 82a038d commit cd52ffe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/ParametersModalPanel.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Base64;
2828
import java.util.Set;
2929
import javax.ws.rs.core.MediaType;
30+
import javax.xml.XMLConstants;
3031
import javax.xml.parsers.ParserConfigurationException;
3132
import javax.xml.parsers.SAXParserFactory;
3233
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -48,8 +49,6 @@ public class ParametersModalPanel extends AbstractModalPanel<ConfParam> {
4849

4950
protected static final JsonMapper JSON_MAPPER = JsonMapper.builder().findAndAddModules().build();
5051

51-
protected static final SAXParserFactory SAX_PARSER_FACTORY = SAXParserFactory.newInstance();
52-
5352
protected static boolean isDate(final String value) {
5453
try {
5554
DateFormatUtils.ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT.parse(value);
@@ -79,9 +78,12 @@ protected static boolean isJSON(final String value) {
7978

8079
protected static boolean isXML(final String value) {
8180
try {
82-
SAX_PARSER_FACTORY.newSAXParser().getXMLReader().parse(new InputSource(new StringReader(value)));
81+
SAXParserFactory factory = SAXParserFactory.newInstance();
82+
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
83+
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
84+
factory.newSAXParser().getXMLReader().parse(new InputSource(new StringReader(value)));
8385
return true;
84-
} catch (IOException | ParserConfigurationException | SAXException xmle) {
86+
} catch (IOException | ParserConfigurationException | SAXException e) {
8587
return false;
8688
}
8789
}

0 commit comments

Comments
 (0)