ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 8031] New: - Suggest ProjectHelperImpl use File.toURI().toURL().toExternalForm()
Date Fri, 12 Apr 2002 18:25:56 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8031>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8031

Suggest ProjectHelperImpl use File.toURI().toURL().toExternalForm()

           Summary: Suggest ProjectHelperImpl use
                    File.toURI().toURL().toExternalForm()
           Product: Ant
           Version: 1.5 alpha (nightly)
          Platform: All
               URL: http://developer.java.sun.com/developer/bugParade/bugs/4
                    472849.html
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Core
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: jesse.glick@netbeans.com


ProjectHelper has for some time used various tricks to ensure that the URL it
passes to the XML parser escapes some nasty filename chars like '#':

revision 1.29
date: 2000/09/14 14:04:38;  author: bodewig;  state: Exp;  lines: +3 -3
Provide the SAXParser with the File instead of an InputSource to give
it a chance to parse relative URIs.

PR: 54
Submitted by:	Achim Dannecker <A.Dannecker@gmx.de>

revision 1.45
date: 2001/01/16 13:36:38;  author: conor;  state: Exp;  lines: +15 -1
Handle directories with # in them by passing the parser
an inputstream, rather than a name.

Submitted by:	Yossie Teitz <yossie@reachcast.co.il>

This is currently handled (now in ProjectHelperImpl.java) by the following code:

String uri = "file:" + buildFile.getAbsolutePath().replace('\\', '/');
for (int index = uri.indexOf('#'); index != -1; index = uri.indexOf('#')) {
    uri = uri.substring(0, index) + "%23" + uri.substring(index + 1);
}

which works for this one case, but not others, and furthermore uses undocumented
aspects of the JRE's treatment of file: URLs which may break on some JRE
implementations.

JDK 1.2 had the File.toURL() method, but it did not solve the escaping problem
correctly; see Java bug #4472849 (see link for details).

Fortunately JDK 1.4 lets you do this:

file.toURI().toURL().toExternalForm()

which ought to provide a URL string with all suitable escapes, ready to be sent
to the parser, with semantics guaranteed by the Java platform.

I suggest that ProjectHelperImpl run code similar to this via reflection when
running on JDK 1.4, rather than the current ad-hoc code.

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message