Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 28988 invoked from network); 9 Aug 2010 19:42:18 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Aug 2010 19:42:18 -0000 Received: (qmail 55173 invoked by uid 500); 9 Aug 2010 19:42:18 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 55124 invoked by uid 500); 9 Aug 2010 19:42:17 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 55117 invoked by uid 99); 9 Aug 2010 19:42:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 19:42:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 19:42:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1502323889B3; Mon, 9 Aug 2010 19:41:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r983792 - in /cxf/branches/2.2.x-fixes: ./ tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java Date: Mon, 09 Aug 2010 19:41:00 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100809194100.1502323889B3@eris.apache.org> Author: dkulp Date: Mon Aug 9 19:40:59 2010 New Revision: 983792 URL: http://svn.apache.org/viewvc?rev=983792&view=rev Log: Merged revisions 980880 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r980880 | ema | 2010-07-30 12:07:40 -0400 (Fri, 30 Jul 2010) | 1 line [CXF-2918]:normalize the url like file:/home/cxf/org/apache/../../cxf in URIParserUtil.getAbsoluteURL() ........ Modified: cxf/branches/2.2.x-fixes/ (props changed) cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java cxf/branches/2.2.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java Propchange: cxf/branches/2.2.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java?rev=983792&r1=983791&r2=983792&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java (original) +++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java Mon Aug 9 19:40:59 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/branches/2.2.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java?rev=983792&r1=983791&r2=983792&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java (original) +++ cxf/branches/2.2.x-fixes/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java Mon Aug 9 19:40:59 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