ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Glick <jesse.gl...@sun.com>
Subject Re: svn commit: r899468 - in /ant/antlibs/props/trunk: docs/index.html src/main/org/apache/ant/props/EncodeURLEvaluator.java src/main/org/apache/ant/props/antlib.xml src/tests/antunit/encodeURL-test.xml
Date Sat, 16 Jan 2010 00:48:38 GMT
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-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message