diff --git a/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java b/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java index bfd461478..02ceee3d4 100644 --- a/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java +++ b/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java @@ -26,7 +26,7 @@ public class VersionUtils { private static String version; - private static final Pattern MAJOR_MINOR_PATTERN = Pattern.compile("$([0-9]+).([0-9]+)"); + private static final Pattern MAJOR_MINOR_PATTERN = Pattern.compile("^([0-9]+).([0-9]+)"); private VersionUtils() { // private constructor diff --git a/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/CustomXMLConstants.java b/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/CustomXMLConstants.java new file mode 100644 index 000000000..2342c8b05 --- /dev/null +++ b/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/CustomXMLConstants.java @@ -0,0 +1,10 @@ +package org.correomqtt.plugin.xml_format; + +public final class CustomXMLConstants { + public static final String NULL_NS_URI = ""; + + public static final String FEATURE_DISALLOW_DOCTYPE_DECL = "http://apache.org/xml/features/disallow-doctype-decl"; + private CustomXMLConstants() { + } +} + diff --git a/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/XmlFormatPlugin.java b/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/XmlFormatPlugin.java index 993c1992e..343f503c9 100644 --- a/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/XmlFormatPlugin.java +++ b/plugins/xml-format/src/main/java/org/correomqtt/plugin/xml_format/XmlFormatPlugin.java @@ -143,6 +143,7 @@ private Document getXmlDocument() { private Document createXmlDocument() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { + factory.setFeature(CustomXMLConstants.FEATURE_DISALLOW_DOCTYPE_DECL, true); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); } catch (ParserConfigurationException e) { LOGGER.debug("Could not configure document builder factory. ", e); @@ -184,6 +185,7 @@ public String getPrettyString() { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer; try { + transformerFactory.setFeature(CustomXMLConstants.FEATURE_DISALLOW_DOCTYPE_DECL, true); transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); transformer = transformerFactory.newTransformer(); } catch (TransformerConfigurationException e) {