gnodet commented on code in PR #1205:
URL: https://github.com/apache/maven/pull/1205#discussion_r1446522303


##########
maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java:
##########
@@ -100,14 +104,39 @@ private Path getRootDirectory(Map<String, ?> options) {
         return (Path) value;
     }
 
+    private boolean getXInclude(Map<String, ?> options) {
+        Object value = (options != null) ? options.get(XINCLUDE) : null;
+        return value instanceof Boolean && (Boolean) value;
+    }
+
     private Model read(InputStream input, Path pomFile, Map<String, ?> 
options) throws IOException {
         try {
-            XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory();
-            
factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
-            XMLStreamReader parser = factory.createXMLStreamReader(input);
-
             InputSource source = getSource(options);
             boolean strict = isStrict(options);
+            Path rootDirectory = getRootDirectory(options);
+
+            Source xmlSource;
+            if (pomFile != null) {
+                if (input != null) {
+                    xmlSource = new StaxPathInputSource(pomFile, input);
+                } else {
+                    xmlSource = new Stax2FileSource(pomFile.toFile());
+                }
+            } else {
+                xmlSource = new StreamSource(input);
+            }
+
+            XMLStreamReader parser;
+            // We only support xml entities and xinclude when reading a file 
in strict mode
+            if (pomFile != null && strict && getXInclude(options)) {
+                parser = XInclude.xinclude(xmlSource, new 
LocalXmlResolver(rootDirectory));
+            } else {
+                XMLInputFactory factory = new 
com.ctc.wstx.stax.WstxInputFactory();
+                
factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
+                
factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);

Review Comment:
   > Nothing you can do here, but this property should have been named 
SUPPORTS_EXTERNAL_ENTITIES
   
   Agreed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to