Hi,

  I found that Ant 1.3 Beta 1 fails to handle the following build.xml
with external entity reference. And the following is the patch.

<!DOCTYPE project [
  <!ENTITY depth "../../..">
  <!ENTITY package "">
  <!ENTITY build.inc SYSTEM "build.inc">
]>

<project name="log4j" default="Usage" basedir="." >
  &build.inc;
</project>

---
Index: src/main/org/apache/tools/ant/ProjectHelper.java
===================================================================
RCS file: 
/home/topware/cvsroot/Enhydra/modules/Ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
retrieving revision 1.1.2.3
diff -c -r1.1.2.3 ProjectHelper.java
*** src/main/org/apache/tools/ant/ProjectHelper.java    2001/02/06 06:24:12     
1.1.2.3
--- src/main/org/apache/tools/ant/ProjectHelper.java    2001/02/06 08:08:06
***************
*** 104,111 ****
              SAXParser saxParser = getParserFactory().newSAXParser();
              parser = saxParser.getParser();
              
!             inputStream = new FileInputStream(buildFile);
!             saxParser.parse(inputStream, new RootHandler());
          }
          catch(ParserConfigurationException exc) {
              throw new BuildException("Parser has not been configured 
correctly", exc);
--- 104,110 ----
              SAXParser saxParser = getParserFactory().newSAXParser();
              parser = saxParser.getParser();
              
!             saxParser.parse(buildFile, new RootHandler());
          }
          catch(ParserConfigurationException exc) {
              throw new BuildException("Parser has not been configured 
correctly", exc);
***************
*** 216,227 ****
                      file = new File(buildFileParent, path);
                  }
                  
!                 try {
!                     return new InputSource(new FileInputStream(file));
!                 } catch (FileNotFoundException fne) {
!                     project.log(file.getAbsolutePath()+" could not be found", 
!                                 Project.MSG_WARN);
!                 }
              }
              // use default if not file or file not found
              return null;
--- 215,221 ----
                      file = new File(buildFileParent, path);
                  }
                  
!               return new InputSource(file.getAbsolutePath());
              }
              // use default if not file or file not found
              return null;

Reply via email to