From a42af181532d497583767a07ace4ef8c46f0a05e Mon Sep 17 00:00:00 2001 From: Arun Venmany Date: Wed, 7 Aug 2024 09:46:03 +0530 Subject: [PATCH] using access extenal dtd property as not allowed in xmleventreader of lemminx Signed-off-by: Arun Venmany --- .../openliberty/tools/langserver/lemminx/util/XmlReader.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lemminx-liberty/src/main/java/io/openliberty/tools/langserver/lemminx/util/XmlReader.java b/lemminx-liberty/src/main/java/io/openliberty/tools/langserver/lemminx/util/XmlReader.java index c730ab88..138bcefe 100644 --- a/lemminx-liberty/src/main/java/io/openliberty/tools/langserver/lemminx/util/XmlReader.java +++ b/lemminx-liberty/src/main/java/io/openliberty/tools/langserver/lemminx/util/XmlReader.java @@ -25,6 +25,7 @@ import java.util.Set; import java.util.logging.Logger; +import javax.xml.XMLConstants; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -92,6 +93,7 @@ private static XMLInputFactory getXmlInputFactory() { factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); + factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); } catch (Exception e) { LOGGER.warning("Could not set properties on XMLInputFactory."); } @@ -114,7 +116,7 @@ public static Map getElementValues(Path file, Set elemen } Map returnValues = new HashMap (); - XMLInputFactory factory = XMLInputFactory.newInstance(); + XMLInputFactory factory = getXmlInputFactory(); XMLEventReader reader = null; try { reader = factory.createXMLEventReader(new FileInputStream(file.toFile()));