You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2014/11/18 15:22:30 UTC
svn commit: r1640349 - in /tomcat/tc8.0.x/trunk: ./
java/org/apache/catalina/core/LocalStrings.properties
java/org/apache/catalina/core/StandardContext.java
test/org/apache/catalina/core/TestStandardContext.java
webapps/docs/changelog.xml
Author: kkolinko
Date: Tue Nov 18 14:22:30 2014
New Revision: 1640349
URL: http://svn.apache.org/r1640349
Log:
Further fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57216
Warn and correct invalid context paths that end with a '/'
Merged r1640347 from tomcat/trunk.
Modified:
tomcat/tc8.0.x/trunk/ (props changed)
tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties
tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
tomcat/tc8.0.x/trunk/test/org/apache/catalina/core/TestStandardContext.java
tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc8.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1640347
Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1640349&r1=1640348&r2=1640349&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/LocalStrings.properties Tue Nov 18 14:22:30 2014
@@ -131,7 +131,7 @@ standardContext.notStarted=Context with
standardContext.notWrapper=Child of a Context must be a Wrapper
standardContext.parameter.duplicate=Duplicate context initialization parameter {0}
standardContext.parameter.required=Both parameter name and parameter value are required
-standardContext.pathInvalid=A context path must either be an empty string or start with a ''/''. The path [{0}] does not meet these criteria and has been changed to [{1}]
+standardContext.pathInvalid=A context path must either be an empty string or start with a ''/'' and do not end with a ''/''. The path [{0}] does not meet these criteria and has been changed to [{1}]
standardContext.postconstruct.duplicate=Duplicate post construct method definition for class {0}
standardContext.postconstruct.required=Both fully qualified class name and method name are required
standardContext.predestroy.duplicate=Duplicate pre destroy method definition for class {0}
Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1640349&r1=1640348&r2=1640349&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Tue Nov 18 14:22:30 2014
@@ -2010,13 +2010,17 @@ public class StandardContext extends Con
public void setPath(String path) {
boolean invalid = false;
if (path == null || path.equals("/")) {
+ invalid = true;
this.path = "";
+ } else if ("".equals(path) || path.startsWith("/")) {
+ this.path = path;
+ } else {
invalid = true;
- } else if (!path.equals("") && !path.startsWith("/")) {
this.path = "/" + path;
+ }
+ if (this.path.endsWith("/")) {
invalid = true;
- } else {
- this.path = path;
+ this.path = this.path.substring(0, this.path.length() - 1);
}
if (invalid) {
log.warn(sm.getString(
Modified: tomcat/tc8.0.x/trunk/test/org/apache/catalina/core/TestStandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/test/org/apache/catalina/core/TestStandardContext.java?rev=1640349&r1=1640348&r2=1640349&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/test/org/apache/catalina/core/TestStandardContext.java (original)
+++ tomcat/tc8.0.x/trunk/test/org/apache/catalina/core/TestStandardContext.java Tue Nov 18 14:22:30 2014
@@ -944,4 +944,22 @@ public class TestStandardContext extends
Assert.assertThat(Arrays.asList(context.getResourceOnlyServlets().split(",")),
CoreMatchers.hasItems("a", "b", "c"));
}
+
+ @Test
+ public void testSetPath() {
+ testSetPath("", "");
+ testSetPath("/foo", "/foo");
+ testSetPath("/foo/bar", "/foo/bar");
+ testSetPath(null, "");
+ testSetPath("/", "");
+ testSetPath("foo", "/foo");
+ testSetPath("/foo/bar/", "/foo/bar");
+ testSetPath("foo/bar/", "/foo/bar");
+ }
+
+ private void testSetPath(String value, String expectedValue) {
+ StandardContext context = new StandardContext();
+ context.setPath(value);
+ Assert.assertEquals(expectedValue, context.getPath());
+ }
}
Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1640349&r1=1640348&r2=1640349&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Tue Nov 18 14:22:30 2014
@@ -61,10 +61,13 @@
a patch provided by Jason McIntosh. (violetagg)
</fix>
<fix>
- <bug>57216</bug>: Improve handling of invalid context paths. A value of
- <code>null</code> is now correctly changed to <code>""</code>
- and a value of <code>"/"</code> is now also changed to
- <code>""</code> and logged as invalid. (markt)
+ <bug>57216</bug>: Improve handling of invalid context paths. A context
+ path should either be an empty string or start with a
+ <code>'/'</code> and do not end with a
+ <code>'/'</code>. Invalid context path are automatically
+ corrected and a warning is logged. The <code>null</code> and
+ <code>"/"</code> values are now correctly changed to
+ <code>""</code>. (markt/kkolinko)
</fix>
<fix>
Update storeconfig with the CredentialHandler element. (remm)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org