File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -609,9 +609,15 @@ public void fatalError(SAXParseException e) throws SAXException {
609609 throw e ;
610610 }
611611
612- public static void load (Theme theme , InputStream in ) throws IOException {
612+ public static void load (Theme theme , InputStream in ) throws IOException {
613613 SAXParserFactory spf = SAXParserFactory .newInstance ();
614614 spf .setValidating (true );
615+
616+ // Disable external entity resolution to prevent XXE attacks
617+ spf .setFeature ("http://xml.org/sax/features/external-general-entities" , false );
618+ spf .setFeature ("http://xml.org/sax/features/external-parameter-entities" , false );
619+ spf .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false );
620+
615621 try {
616622 SAXParser parser = spf .newSAXParser ();
617623 XMLReader reader = parser .getXMLReader ();
@@ -624,8 +630,8 @@ public static void load(Theme theme, InputStream in) throws IOException {
624630 InputSource is = new InputSource (in );
625631 is .setEncoding ("UTF-8" );
626632 reader .parse (is );
627- } catch (/*SAX|ParserConfiguration*/ Exception se ) {
628- throw new IOException (se .toString () );
633+ } catch (SAXException | ParserConfigurationException se ) {
634+ throw new IOException ("Error parsing XML: " + se .getMessage (), se );
629635 }
630636 }
631637
You can’t perform that action at this time.
0 commit comments