David, Sorry, I saw your earlier post on this subject but didn't get around to addressing it. I am not an expert on XML entity declarations but I did some background research on this.
Firstly, let me point you to this patch, applied about a month ago which is the reverse of the first part of your patch http://jakarta.apache.org/cvsweb/index.cgi/jakarta-ant/src/main/org/apache/ tools/ant/ProjectHelper.java.diff?r1=1.44&r2=1.45&diff_format=h Now I believe that patch was to prevent a # in a directory name being interpreted as a URL fragment separator. This used to fail and I can only assume that JAXP is converting the File object in this call public void parse(File file, HandlerBase base) into a file: URL and then invoking public void parse(String uri, HandlerBase base) Maybe, that is not a good approach. According to the XML spec, the SystemLiteral is a URI as defined in RFC2396/RFC2732. I am not sure how the XML parser will interpret the build.inc in <!ENTITY build.inc SYSTEM "build.inc"> as a URI. The second part of your patch is in an if block if (systemId.startsWith("file:")) { so it is unlikely that "build.inc" will trigger the changed code. I would be inclined to change your "build.inc" to "file:build.inc" as presented in the FAQ. Otherwise, we would have to exclude directories which include the # character from being used with Ant. To quote the original bug report "This bug is particularly nasty for us since we use the Continuus configuration management system which likes to place projects under a directory named projectName#userName. This bug renders ANT unusable in our environment. " Also, to test this I checked out log4j and did not find the exact construction you mention. I did find a lot of references to build.inc but no build.inc itself. I'd be interested in comments on this. My inclination is to say this is not a bug. Conor ----- Original Message ----- From: "David Li" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 16, 2001 6:04 PM Subject: [PATCH to Bug 625] Incorrect handling of External Entity... > Problem is as following. The patch is attached... > > The project file readers does not handle external entity correctly. The > following build.xml is from Jakarta Log4J project. The current Ant 1.3 > Beta 2 > can not handle this build.xml > > The file in question is > > src/main/org/apache/tools/ant/ProjectHelper.java > > > <!-- This file is intended for ANT, a Java based build tool. ANT is > availale from http://jakarta.apache.org/ant/index.html > --> > > <!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/Pro jectHelper.java,v > retrieving revision 1.1.2.5 > diff -c -r1.1.2.5 ProjectHelper.java > *** src/main/org/apache/tools/ant/ProjectHelper.java 2001/02/16 06:36:00 1.1.2.5 > --- src/main/org/apache/tools/ant/ProjectHelper.java 2001/02/16 06:50:11 > *************** > *** 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); > *************** > *** 215,227 **** > if (!file.isAbsolute()) { > 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; > --- 214,220 ---- > if (!file.isAbsolute()) { > file = new File(buildFileParent, path); > } > ! return new InputSource(file.getAbsolutePath()); > } > // use default if not file or file not found > return null; > > --------------------------------------------------------------------------- ----- > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
