@@ -17,15 +17,15 @@ public void unsafeSource(Socket sock) throws Exception {
17
17
SAXSource source = new SAXSource (reader , new InputSource (sock .getInputStream ()));
18
18
JAXBContext jc = JAXBContext .newInstance (Object .class );
19
19
Unmarshaller um = jc .createUnmarshaller ();
20
- um .unmarshal (source ); //unsafe
20
+ um .unmarshal (source ); // BAD
21
21
}
22
22
23
23
public void explicitlySafeSource1 (Socket sock ) throws Exception {
24
24
XMLReader reader = XMLReaderFactory .createXMLReader ();
25
25
reader .setFeature ("http://xml.org/sax/features/external-general-entities" , false );
26
26
reader .setFeature ("http://xml.org/sax/features/external-parameter-entities" , false );
27
27
reader .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" ,false );
28
- SAXSource source = new SAXSource (reader , new InputSource (sock .getInputStream ())); //safe
28
+ SAXSource source = new SAXSource (reader , new InputSource (sock .getInputStream ())); // GOOD
29
29
}
30
30
31
31
public void createdSafeSource (Socket sock ) throws Exception {
@@ -35,7 +35,7 @@ public void createdSafeSource(Socket sock) throws Exception {
35
35
factory .setFeature ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , false );
36
36
SAXParser parser = factory .newSAXParser ();
37
37
XMLReader reader = parser .getXMLReader ();
38
- SAXSource source = new SAXSource (parser .getXMLReader (), new InputSource (sock .getInputStream ())); //safe
39
- SAXSource source2 = new SAXSource (reader , new InputSource (sock .getInputStream ())); //safe
38
+ SAXSource source = new SAXSource (parser .getXMLReader (), new InputSource (sock .getInputStream ())); // GOOD
39
+ SAXSource source2 = new SAXSource (reader , new InputSource (sock .getInputStream ())); // GOOD
40
40
}
41
41
}
0 commit comments