File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
service/src/main/java/org/lfenergy/compas/scl/validator/common Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import org .lfenergy .compas .scl .validator .exception .SclValidatorException ;
7
7
8
+ import javax .xml .XMLConstants ;
8
9
import javax .xml .stream .XMLInputFactory ;
9
10
import javax .xml .stream .XMLStreamException ;
10
11
import javax .xml .stream .events .StartElement ;
@@ -25,8 +26,16 @@ public class NsdocInfo {
25
26
26
27
public NsdocInfo (File file ) {
27
28
try (var fis = new FileInputStream (file )) {
28
- var xmlInputFactory = XMLInputFactory .newInstance ();
29
- var reader = xmlInputFactory .createXMLEventReader (fis );
29
+ var factory = XMLInputFactory .newInstance ();
30
+ // to be compliant, completely disable DOCTYPE declaration:
31
+ factory .setProperty (XMLInputFactory .SUPPORT_DTD , false );
32
+ // or completely disable external entities declarations:
33
+ factory .setProperty (XMLInputFactory .IS_SUPPORTING_EXTERNAL_ENTITIES , Boolean .FALSE );
34
+ // or prohibit the use of all protocols by external entities:
35
+ factory .setProperty (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
36
+ factory .setProperty (XMLConstants .ACCESS_EXTERNAL_SCHEMA , "" );
37
+
38
+ var reader = factory .createXMLEventReader (fis );
30
39
31
40
while (id == null && reader .hasNext ()) {
32
41
processEvent (reader .nextEvent ());
You can’t perform that action at this time.
0 commit comments