You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/03/01 16:56:48 UTC
svn commit: r1733093 - in /tomcat/trunk:
java/org/apache/catalina/startup/ClassLoaderFactory.java
java/org/apache/tomcat/util/buf/UriUtil.java
test/org/apache/tomcat/util/buf/TestUriUtil.java
Author: markt
Date: Tue Mar 1 15:56:47 2016
New Revision: 1733093
URL: http://svn.apache.org/viewvc?rev=1733093&view=rev
Log:
Review comments from kkolinko for r1733077
Added:
tomcat/trunk/test/org/apache/tomcat/util/buf/TestUriUtil.java (with props)
Modified:
tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java
Modified: tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java?rev=1733093&r1=1733092&r2=1733093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java Tue Mar 1 15:56:47 2016
@@ -280,7 +280,7 @@ public final class ClassLoaderFactory {
* org.apache.tomcat.util.buf.UriUtil but that class is not visible until
* after the class loaders have been constructed.
*/
- public static URL buildClassLoaderUrl(String urlString) throws MalformedURLException {
+ private static URL buildClassLoaderUrl(String urlString) throws MalformedURLException {
// URLs passed to class loaders may point to directories that contain
// JARs. If these URLs are used to construct URLs for resources in a JAR
// the URL will be used as is. It is therefore necessary to ensure that
@@ -290,9 +290,9 @@ public final class ClassLoaderFactory {
}
- public static URL buildClassLoaderUrl(File file) throws MalformedURLException {
+ private static URL buildClassLoaderUrl(File file) throws MalformedURLException {
// Could be a directory or a file
- String fileUrlString = file.toURI().toURL().toString();
+ String fileUrlString = file.toURI().toString();
fileUrlString = fileUrlString.replaceAll("!/", "%21/");
return new URL(fileUrlString);
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java?rev=1733093&r1=1733092&r2=1733093&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java Tue Mar 1 15:56:47 2016
@@ -71,7 +71,7 @@ public final class UriUtil {
public static URL buildJarUrl(File jarFile, String entryPath) throws MalformedURLException {
- return buildJarUrl(jarFile.toURI().toURL().toString(), entryPath);
+ return buildJarUrl(jarFile.toURI().toString(), entryPath);
}
@@ -94,7 +94,7 @@ public final class UriUtil {
public static URL buildJarSafeUrl(File file) throws MalformedURLException {
- String safe = makeSafeForJarUrl(file.toURI().toURL().toString());
+ String safe = makeSafeForJarUrl(file.toURI().toString());
return new URL(safe);
}
Added: tomcat/trunk/test/org/apache/tomcat/util/buf/TestUriUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/buf/TestUriUtil.java?rev=1733093&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/buf/TestUriUtil.java (added)
+++ tomcat/trunk/test/org/apache/tomcat/util/buf/TestUriUtil.java Tue Mar 1 15:56:47 2016
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.buf;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestUriUtil {
+
+ @Test
+ public void testBuildJarUrl01() throws MalformedURLException {
+ File jarFile = new File("/patha/pathb!/pathc");
+ String result = UriUtil.buildJarUrl(jarFile).toString();
+
+ int index = result.indexOf("!/");
+ Assert.assertEquals(result, result.length() - 2, index);
+ }
+
+
+ @Test
+ public void testBuildJarUrl02() throws MalformedURLException {
+ File jarFile = new File("/patha/pathb*/pathc");
+ String result = UriUtil.buildJarUrl(jarFile).toString();
+
+ int index = result.indexOf("!/");
+ Assert.assertEquals(result, result.length() - 2, index);
+
+ index = result.indexOf("*/");
+ Assert.assertEquals(result, -1, index);
+ }
+
+
+ @Test
+ public void testBuildJarUrl03() throws MalformedURLException {
+ File jarFile = new File("/patha/pathb^/pathc");
+ String result = UriUtil.buildJarUrl(jarFile).toString();
+
+ int index = result.indexOf("!/");
+ Assert.assertEquals(result, result.length() - 2, index);
+
+ index = result.indexOf("^/");
+ Assert.assertEquals(result, -1, index);
+ }
+}
Propchange: tomcat/trunk/test/org/apache/tomcat/util/buf/TestUriUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org