* {@link <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42222">Locator implementation not encoding URI strings properly: spaces in paths</a>}
* It also breaks Eclipse 3.3 Betas
* {@link <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=183283">Exception if installation path has spaces</a>}
*
* Be very careful when making changes to this class, as a break will upset a lot of people.
* @since Ant 1.6
*/
public final class Locator {
@@ -151,12 +161,28 @@ public final class Locator {
* @since Ant 1.6
*/
public static String fromURI(String uri) {
// #8031: first try Java 1.4.
// #buzilla8031: first try Java 1.4.
String result = null;
//result = fromUriJava14(uri);
if (result == null) {
result = fromURIJava13(uri);
}
return result;
}
/**
* Java1.4+ code to extract the path from the URI.
* @param uri
* @return null if a conversion was not possible
*/
private static String fromUriJava14(String uri) {
Class uriClazz = null;
try {
uriClazz = Class.forName("java.net.URI");
} catch (ClassNotFoundException cnfe) {
// Fine, Java 1.3 or earlier, do it by hand.
return null;
}
// Also check for properly formed URIs. Ant formerly recommended using
// nonsense URIs such as "file:./foo.xml" in XML includes. You shouldn't
@@ -165,18 +191,22 @@ public final class Locator {
if (uriClazz != null && uri.startsWith("file:/")) {
try {
java.lang.reflect.Method createMethod
= uriClazz.getMethod("create", new Class[]{String.class});
Object uriObj = createMethod.invoke(null, new Object[]{encodeURI(uri)});
= uriClazz.getMethod("create", new Class[]{String.class});
Object uriObj = createMethod.invoke(null, new Object[]{encodeURI(uri)});
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.