Skip to content

Commit 820192c

Browse files
HaxatronAngledLuffa
authored andcommitted
Fix SAXParser security issue
1 parent 76666dd commit 820192c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/edu/stanford/nlp/process/TransformXML.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.*;
66
import java.util.*;
77

8+
import javax.xml.XMLConstants;
89
import javax.xml.parsers.SAXParser;
910
import javax.xml.parsers.SAXParserFactory;
1011

@@ -195,7 +196,9 @@ public void processText(String text) {
195196

196197
public TransformXML() {
197198
try {
198-
saxParser = SAXParserFactory.newInstance().newSAXParser();
199+
SAXParserFactory spf = SAXParserFactory.newInstance();
200+
spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
201+
saxParser = spf.newSAXParser();
199202
} catch (Exception e) {
200203
log.info("Error configuring XML parser: " + e);
201204
throw new RuntimeException(e);

0 commit comments

Comments
 (0)