Matt Benson wrote:
Java 5 blows up when call toURI() against a URL with a space included.

Which is correct; such a URL is invalid:

$ jrunscript
js> new java.net.URL("file:/tmp/foo bar").toURI()
script error: sun.org.mozilla.javascript.internal.WrappedException: Wrapped java.net.URISyntaxException: Illegal character in path at index 13: file:/tmp/foo bar (<STDIN>#1) in <STDIN> at line number 1
js> new java.net.URL("file:/tmp/foo%20bar").toURI()
file:/tmp/foo%20bar

Maybe I'm missing the purpose of EncodeURLEvaluator, but where would you get a bogus URL like that from to begin with? Surely not from <makeurl> on a file, which ought to escape spaces in filenames. I assumed that the purpose was just to encode non-ASCII characters, for which toURI is fine:

js> new java.net.URL("file:/tmp/foočbar").toURI().toASCIIString()
file:/tmp/foo%C4%8Dbar

Or are you trying to encode path sequences (rather than complete URLs)? But 
then there is an easier way, without using URL at all:

js> new java.net.URI(null, "foo bar", null).rawPath
foo%20bar

Anyway does this belong in Ant 1.8.0 so late in the release cycle?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to