Bug 43364 - SimpleAntArtifact throws URISyntaxException when ArtifactLocation contains spaces
SimpleAntArtifact throws URISyntaxException when ArtifactLocation contains sp...
Status: CLOSED FIXED
Product: projects
Classification: Unclassified
Component: Ant
4.x
All All
: P3 (vote)
: 4.x
Assigned To: David Konecny
issues@projects
: API, SPACE_IN_PATH
Depends on:
Blocks: 41535
  Show dependency treegraph
 
Reported: 2004-05-17 14:04 UTC by David Konecny
Modified: 2006-03-24 10:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2004-05-17 14:04:24 UTC
If you replace "dist/proj3.jar" with "d i s t/p r
o j 3.jar" in ReferenceHelperTest unit test you
will get the %SUBJ% exception.

Jesse, why AntArtifact.getArtifactLocation()
returns URI? Is that necessary? I think the String
would be more appropriate.

Otherwise the String must be encoded to be usable
for URI construction. AFAIK there is not method
for this conversion.

Unless you want to fix this yourself I can do it.
Just let me know your preference.
Comment 1 Jesse Glick 2004-05-17 16:44:02 UTC
Please do fix it.

The reason for using URI is that it could be either relative
("dist/foo.jar") or absolute ("file:/tmp/foo.jar") and URI provides a
reliable way of differentiating these. Note
AntArtifact.getArtifactFile impl. I suppose it could also be a String,
either a relative or absolute path, though it is less reliable to tell
which you have in that case I think. No strong opinion.

For "d i s t/p r o j 3.jar" the URI should be "d%20i%20.....3.jar".

For "/tmp/f o o.jar" the URI should be "file:/tmp/f%20o%20o.jar".
Comment 2 David Konecny 2004-05-17 16:47:19 UTC
If it is just a matter of replacing " " with "%20" I would leave there
URI and fix it.
Comment 3 Jesse Glick 2004-05-17 16:55:31 UTC
Well, ' ' -> "%20" and other substitutions for illegal URI characters...

For absolute paths you should be using new File(path).toURI(). For
relative paths, maybe there is some kind of utility method to encode
special characters properly? Can't you do this with a special URI
constructor, perhaps?
Comment 4 David Konecny 2004-05-17 17:43:37 UTC
You say URI with special constructor, hmmm, that was pretty easy. I
should think twice next time before asking dumb questions. Sorry.

Fixed:
src/org/netbeans/spi/project/support/ant/ReferenceHelper.java;
new revision: 1.9; previous revision: 1.8
src/org/netbeans/spi/project/support/ant/SimpleAntArtifact.java;
new revision: 1.6; previous revision: 1.5
test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java;
new revision: 1.9; previous revision: 1.8
Comment 5 Jaromir Uhrik 2005-07-14 16:19:28 UTC
Verified.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo