Author: maartenc
Date: Wed Aug 20 15:30:44 2008
New Revision: 687492

URL: http://svn.apache.org/viewvc?rev=687492&view=rev
Log:
FIX: URLRepository does not allow some valid file scheme uri's (IVY-884)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
    
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/URLResolverTest.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=687492&r1=687491&r2=687492&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Aug 20 15:30:44 2008
@@ -108,6 +108,7 @@
 - IMPROVEMENT: Add a memory cache for the module descriptor that are parsed 
from the cache (IVY-883)
 - IMPROVEMENT: Improve performance (IVY-872)
 
+- FIX: URLRepository does not allow some valid file scheme uri's (IVY-884)
 - FIX: Incorrect parsing artifactPattern attribute in a sftp resolver 
(IVY-661) (thanks to Alexey Kiselev)
 - FIX: Maven2 "ejb" packaging is not supported (IVY-873)
 - FIX: Config files with # in path can't be read (IVY-868) (thanks to Simon 
Steiner)

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java?rev=687492&r1=687491&r2=687492&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
 (original)
+++ 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
 Wed Aug 20 15:30:44 2008
@@ -19,6 +19,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.*;
 import org.apache.ivy.plugins.repository.AbstractRepository;
@@ -106,7 +108,15 @@
                 return ret;
             }
         } else if (parent.startsWith("file")) {
-            String path = new URL(parent).getPath();
+            String path;
+            try {
+                path = new URI(parent).getPath();
+            } catch (URISyntaxException e) {
+                IOException ioe = new IOException("Couldn't list content of '" 
+ parent + "'");
+                ioe.initCause(e);
+                throw ioe;
+            }
+            
             File file = new File(path);
             if (file.exists() && file.isDirectory()) {
                 String[] files = file.list();

Modified: 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/URLResolverTest.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/URLResolverTest.java?rev=687492&r1=687491&r2=687492&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/URLResolverTest.java
 (original)
+++ 
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/URLResolverTest.java
 Wed Aug 20 15:30:44 2008
@@ -121,11 +121,9 @@
     public void testLatestFile() throws Exception {
         URLResolver resolver = new URLResolver();
         resolver.setSettings(_settings);
-        String rootpath = new 
File("test/repositories/1").getAbsolutePath().replaceAll("\\\\", "/");
-        resolver.addIvyPattern("file:" + rootpath
-                + "/[organisation]/[module]/ivys/ivy-[revision].xml");
-        resolver.addArtifactPattern("file:" + rootpath
-                + 
"/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
+        String rootpath = new 
File("test/repositories/1").toURI().toURL().toExternalForm();
+        resolver.addIvyPattern(rootpath + 
"[organisation]/[module]/ivys/ivy-[revision].xml");
+        resolver.addArtifactPattern(rootpath + 
"[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
         resolver.setName("test");
         assertEquals("test", resolver.getName());
 


Reply via email to