File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
shogun-gs-interceptor/src/main/java/de/terrestris/shogun/interceptor/util Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -85,15 +85,21 @@ public static Document getDocumentFromString(String xml) throws IOException {
8585 InputSource source = new InputSource (new StringReader (xml ));
8686 DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
8787
88- // limit resolution of external entities, see https://rules.sonarsource.com/c/type/Vulnerability/RSPEC-2755
89- factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
90- factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_SCHEMA , "" );
88+ try {
89+ // limit resolution of external entities, see https://rules.sonarsource.com/c/type/Vulnerability/RSPEC-2755
90+ factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
91+ factory .setAttribute (XMLConstants .ACCESS_EXTERNAL_SCHEMA , "" );
92+ } catch (IllegalArgumentException e ) {
93+ log .error ("External DTD/Schema access properties not supported:"
94+ + e .getMessage ());
95+ }
9196
9297 DocumentBuilder builder = factory .newDocumentBuilder ();
9398 document = builder .parse (source );
94- } catch (ParserConfigurationException | SAXException | IOException e ) {
95- throw new IOException ("Could not parse input body " +
96- "as XML: " + e .getMessage ());
99+ } catch (IllegalArgumentException | ParserConfigurationException
100+ | SAXException | IOException e ) {
101+ throw new IOException ("Could not parse input body as XML: "
102+ + e .getMessage ());
97103 }
98104 return document ;
99105 }
You can’t perform that action at this time.
0 commit comments