cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r980880 - in /cxf/trunk/tools/common/src: main/java/org/apache/cxf/tools/util/URIParserUtil.java test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
Date Fri, 30 Jul 2010 16:07:40 GMT
Author: ema
Date: Fri Jul 30 16:07:40 2010
New Revision: 980880

URL: http://svn.apache.org/viewvc?rev=980880&view=rev
Log:
[CXF-2918]:normalize the url like file:/home/cxf/org/apache/../../cxf in URIParserUtil.getAbsoluteURL()

Modified:
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
    cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java?rev=980880&r1=980879&r2=980880&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java Fri
Jul 30 16:07:40 2010
@@ -248,18 +248,15 @@ public final class URIParserUtil {
     }
     public static String normalize(final String uri) {
         URL url = null;
+        String result = null;
         try {
             url = new URL(uri);
-            return escapeChars(url.toString().replace("\\", "/"));
+            result = escapeChars(url.toURI().normalize().toString().replace("\\", "/"));
         } catch (MalformedURLException e1) {
             try {
-                if (uri.startsWith("classpath:")) {
-                    
+                if (uri.startsWith("classpath:")) {                  
                     url = ClassLoaderUtils.getResource(uri.substring(10), URIParserUtil.class);
-                    if (url != null) {
-                        return url.toExternalForm();
-                    }
-                    return uri;
+                    return url != null ? url.toExternalForm() : uri;
                 }
                 File file = new File(uri);
                 if (file.exists()) {
@@ -276,7 +273,12 @@ public final class URIParserUtil {
             } catch (Exception e2) {
                 return escapeChars(uri.replace("\\", "/"));
             }
+        } catch (URISyntaxException e) {
+            if (url != null) {
+                result = escapeChars(url.toString().replace("\\", "/"));
+            }
         }
+        return result;
     }
 
     public static String getAbsoluteURI(final String arg) {

Modified: cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java?rev=980880&r1=980879&r2=980880&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
(original)
+++ cxf/trunk/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
Fri Jul 30 16:07:40 2010
@@ -56,6 +56,9 @@ public class URIParserUtilTest extends A
 
         uri = "/c:\\hello.wsdl";
         assertEquals("file:/c:/hello.wsdl", URIParserUtil.normalize(uri));
+        
+        uri = "file:/home/john/test/all/../../alltest";
+        assertEquals("file:/home/john/alltest", URIParserUtil.normalize(uri));
     }
 
     @Test



Mime
View raw message