Symbol ``['' and a java.net.URI.create method
Christopher Hegarty - Sun Microsystems Ireland
Christopher.Hegarty at Sun.COM
Sat May 10 07:58:13 PDT 2008
Thanks for the update Michal.
It is nice to know that even though this was not our bug we were able to
help diagnose the problem.
-Chris.
Michal Vyskocil wrote:
> On Tuesday 29 April 2008 18:21:43 Christopher Hegarty - Sun Microsystems
> Ireland wrote:
>> The square bracket characters ('[' and ']') are reserved characters
>> in a URI. If they are to be used then they need to percent encoded.
>> That is, '[' is percent encoded to be %5B.
>>
>> The single argument java.net.URI constructor requires any illegal
>> characters in its argument to be quoted and preserves any escaped
>> octets and other characters that are present. The static create
>> method simply invokes the URI(String) constructor, with some extra
>> Exception handling. Therefore any reserved characters need to be
>> percent encoded before passing the String as an argument.
>>
>> You can look at the java.net.URI class description to give you a
>> better understanding of how this encoding works.
>
> Hi Chriss,
>
> thanks for your response. There problem was in ant. There are two bugs -
> missing encodeUri and a decodeUri calls in a
> org.apache.tools.ant.launch.Locator.createUri - both was fixed in
> upstream - r539002 and r533024.
>
> For ant 1.7.0 is this simple patch, just
>
> --- src/main/org/apache/tools/ant/launch/Locator.java
> +++ src/main/org/apache/tools/ant/launch/Locator.java
> @@ -159,11 +159,14 @@
> try {
> java.lang.reflect.Method createMethod
> = uriClazz.getMethod("create", new Class[]
> {String.class});
> - Object uriObj = createMethod.invoke(null, new Object[]
> {uri});
> + // encode URI first - to handle [] characters used in a
> + // build-jar-repository in jpackage project
> + Object uriObj = createMethod.invoke(null, new Object[]
> {encodeURI(uri)});
> java.lang.reflect.Constructor fileConst
> = File.class.getConstructor(new Class[]
> {uriClazz});
> File f = (File) fileConst.newInstance(new Object[]
> {uriObj});
> - return f.getAbsolutePath();
> + //bug #42227 (Apache bugzilla) forgot to decode before
> returning
> + return decodeUri(f.getAbsolutePath());
> } catch (java.lang.reflect.InvocationTargetException e) {
> Throwable e2 = e.getTargetException();
> if (e2 instanceof IllegalArgumentException) {
>
> Thanks for help!
>
> Regards
> Michal Vyskocil
More information about the net-dev
mailing list