Author: mcucchiara Date: Tue May 24 16:53:44 2011 New Revision: 1127142 URL: http://svn.apache.org/viewvc?rev=1127142&view=rev Log: WW-3626 Corrected URLUtil#normalizeToFileProtocol in order to allow the word jar along the path
Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java?rev=1127142&r1=1127141&r2=1127142&view=diff ============================================================================== --- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java (original) +++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/URLUtil.java Tue May 24 16:53:44 2011 @@ -32,7 +32,7 @@ public class URLUtil { public static final String JBOSS5_VFSMEMORY = "vfsmemory"; public static final String JBOSS5_VFSFILE = "vfsfile"; - private static final Pattern JAR_PATTERN = Pattern.compile("^(jar:|wsjar:|zip:|vfsfile:|code-source:)?(file:)?(.*?)(\\!/|.jar/)(.*)"); + private static final Pattern JAR_PATTERN = Pattern.compile("^(jar:|wsjar:|zip:|vfsfile:|code-source:)?(file:)?(.*?)(\\!/|\\.jar/)(.*)"); private static final int JAR_FILE_PATH = 3; /** @@ -64,7 +64,7 @@ public class URLUtil { * @param url The url string to verify. * @return a boolean indicating whether the URL seems to be incorrect. */ - public final static boolean verifyUrl(String url) { + public static boolean verifyUrl(String url) { if (url == null) { return false; } Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java?rev=1127142&r1=1127141&r2=1127142&view=diff ============================================================================== --- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java (original) +++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java Tue May 24 16:53:44 2011 @@ -34,6 +34,22 @@ public class URLUtilTest extends TestCas assertEquals("file:c:/somefile.jar", outputURL.toExternalForm()); } + public void testJarFileWithJarWordInsidePath() throws MalformedURLException { + URL url = new URL("jar:file:/c:/workspace/projar/somefile.jar!/"); + URL outputURL = URLUtil.normalizeToFileProtocol(url); + + assertNotNull(outputURL); + assertEquals("file:/c:/workspace/projar/somefile.jar", outputURL.toExternalForm()); + + url = new URL("jar:file:/c:/workspace/projar/somefile.jar!/somestuf/bla/bla"); + outputURL = URLUtil.normalizeToFileProtocol(url); + assertEquals("file:/c:/workspace/projar/somefile.jar", outputURL.toExternalForm()); + + url = new URL("jar:file:c:/workspace/projar/somefile.jar!/somestuf/bla/bla"); + outputURL = URLUtil.normalizeToFileProtocol(url); + assertEquals("file:c:/workspace/projar/somefile.jar", outputURL.toExternalForm()); + } + public void testZipFile() throws MalformedURLException { URL url = new URL("zip:/c:/somefile.zip!/"); URL outputURL = URLUtil.normalizeToFileProtocol(url);