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 2014/11/17 09:06:24 UTC

svn commit: r1640089 - in /tomcat/tc8.0.x/trunk: ./ java/org/apache/catalina/core/StandardContext.java webapps/docs/changelog.xml

Author: markt
Date: Mon Nov 17 08:06:24 2014
New Revision: 1640089

URL: http://svn.apache.org/r1640089
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57216
Catch "/" as an invalid setting for context path and improve handling of
null values.

Modified:
    tomcat/tc8.0.x/trunk/   (props changed)
    tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc8.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1640088

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=1640089&r1=1640088&r2=1640089&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 Mon Nov 17 08:06:24 2014
@@ -2008,13 +2008,20 @@ public class StandardContext extends Con
      */
     @Override
     public void setPath(String path) {
-        if (path == null || (!path.equals("") && !path.startsWith("/"))) {
+        boolean invalid = false;
+        if (path == null || path.equals("/")) {
+            path = "";
+            invalid = true;
+        } else if (!path.equals("") && !path.startsWith("/")) {
             this.path = "/" + path;
-            log.warn(sm.getString(
-                    "standardContext.pathInvalid", path, this.path));
+            invalid = true;
         } else {
             this.path = path;
         }
+        if (invalid) {
+            log.warn(sm.getString(
+                    "standardContext.pathInvalid", path, this.path));
+        }
         encodedPath = urlEncoder.encode(this.path);
         if (getName() == null) {
             setName(this.path);

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=1640089&r1=1640088&r2=1640089&view=diff
==============================================================================
--- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Mon Nov 17 08:06:24 2014
@@ -60,6 +60,12 @@
         in a directory context for a user with specified user name. Based on
         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>&quot;&quot;</code>
+        and a value of <code>&quot;/&quot;</code> is now also changed to
+        <code>&quot;&quot;</code> and logged as invalid. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1640089 - in /tomcat/tc8.0.x/trunk: ./ java/org/apache/catalina/core/StandardContext.java webapps/docs/changelog.xml

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-11-18 13:29 GMT+03:00 Mark Thomas <ma...@apache.org>:
> On 18/11/2014 03:48, Konstantin Kolinko wrote:
>> 2014-11-18 5:30 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:
>>> 2014-11-17 11:06 GMT+03:00  <ma...@apache.org>:
>>>> Author: markt
>>>> Date: Mon Nov 17 08:06:24 2014
>>>> New Revision: 1640089
>>>>
>>>> URL: http://svn.apache.org/r1640089
>>>> Log:
>>>> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57216
>>>> Catch "/" as an invalid setting for context path and improve handling of
>>>> null values.
>>>>
>>>
>>> A number of test are failing at Gump.
>>> (They are failing at Buildbot as well, but none e-mails were received).
>>>
>>> E.g.
>>> Test org.apache.catalina.startup.TestListener FAILED
>>>
>>> and I see
>>>     [junit] 18-Nov-2014 01:21:53.447 WARNING [main]
>>> org.apache.catalina.core.StandardContext.setPath A context path must
>>> either be an empty string or start with a '/'. The path [] does not
>>> meet these criteria and has been changed to [null]
>>
>> Fixed by r1640276
>
> Thanks.
>
>> Remaining issues:
>> a) I think that context paths that end with "/" shall be prohibited as well.
>
> Agreed.

Fixed.

>> b) Run the whole testsuite and fix tests to do not use "/" as context path.
>
> Also agreed.

Fixed.

(In Tomcat 9, 8 and 7).

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1640089 - in /tomcat/tc8.0.x/trunk: ./ java/org/apache/catalina/core/StandardContext.java webapps/docs/changelog.xml

Posted by Mark Thomas <ma...@apache.org>.
On 18/11/2014 03:48, Konstantin Kolinko wrote:
> 2014-11-18 5:30 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:
>> 2014-11-17 11:06 GMT+03:00  <ma...@apache.org>:
>>> Author: markt
>>> Date: Mon Nov 17 08:06:24 2014
>>> New Revision: 1640089
>>>
>>> URL: http://svn.apache.org/r1640089
>>> Log:
>>> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57216
>>> Catch "/" as an invalid setting for context path and improve handling of
>>> null values.
>>>
>>> Modified:
>>>     tomcat/tc8.0.x/trunk/   (props changed)
>>>     tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
>>>     tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
>>>
>>> Propchange: tomcat/tc8.0.x/trunk/
>>> ------------------------------------------------------------------------------
>>>   Merged /tomcat/trunk:r1640088
>>>
>>> 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=1640089&r1=1640088&r2=1640089&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 Mon Nov 17 08:06:24 2014
>>> @@ -2008,13 +2008,20 @@ public class StandardContext extends Con
>>>       */
>>>      @Override
>>>      public void setPath(String path) {
>>> -        if (path == null || (!path.equals("") && !path.startsWith("/"))) {
>>> +        boolean invalid = false;
>>> +        if (path == null || path.equals("/")) {
>>> +            path = "";
>>
>> this.path = "";
>>
>>> +            invalid = true;
>>> +        } else if (!path.equals("") && !path.startsWith("/")) {
>>>              this.path = "/" + path;
>>> -            log.warn(sm.getString(
>>> -                    "standardContext.pathInvalid", path, this.path));
>>> +            invalid = true;
>>>          } else {
>>>              this.path = path;
>>>          }
>>> +        if (invalid) {
>>> +            log.warn(sm.getString(
>>> +                    "standardContext.pathInvalid", path, this.path));
>>> +        }
>>>          encodedPath = urlEncoder.encode(this.path);
>>>          if (getName() == null) {
>>>              setName(this.path);
>>
>>
>> A number of test are failing at Gump.
>> (They are failing at Buildbot as well, but none e-mails were received).
>>
>> E.g.
>> Test org.apache.catalina.startup.TestListener FAILED
>>
>> and I see
>>     [junit] 18-Nov-2014 01:21:53.447 WARNING [main]
>> org.apache.catalina.core.StandardContext.setPath A context path must
>> either be an empty string or start with a '/'. The path [] does not
>> meet these criteria and has been changed to [null]
> 
> Fixed by r1640276

Thanks.

> Remaining issues:
> a) I think that context paths that end with "/" shall be prohibited as well.

Agreed.

> b) Run the whole testsuite and fix tests to do not use "/" as context path.

Also agreed.

Mark

> 
> E.g. org.apache.catalina.startup.TestListener now prints the warning
> 
> WARNING [main] org.apache.catalina.core.StandardContext.setPath A
> context path must either be an empty string or start with a '/'. The
> path [/] does not meet these criteria and has been changed to []
> 
> Its code does
>         Context context = tomcat.addContext("/",
>                 System.getProperty("java.io.tmpdir"));
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1640089 - in /tomcat/tc8.0.x/trunk: ./ java/org/apache/catalina/core/StandardContext.java webapps/docs/changelog.xml

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-11-18 5:30 GMT+03:00 Konstantin Kolinko <kn...@gmail.com>:
> 2014-11-17 11:06 GMT+03:00  <ma...@apache.org>:
>> Author: markt
>> Date: Mon Nov 17 08:06:24 2014
>> New Revision: 1640089
>>
>> URL: http://svn.apache.org/r1640089
>> Log:
>> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57216
>> Catch "/" as an invalid setting for context path and improve handling of
>> null values.
>>
>> Modified:
>>     tomcat/tc8.0.x/trunk/   (props changed)
>>     tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
>>     tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
>>
>> Propchange: tomcat/tc8.0.x/trunk/
>> ------------------------------------------------------------------------------
>>   Merged /tomcat/trunk:r1640088
>>
>> 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=1640089&r1=1640088&r2=1640089&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 Mon Nov 17 08:06:24 2014
>> @@ -2008,13 +2008,20 @@ public class StandardContext extends Con
>>       */
>>      @Override
>>      public void setPath(String path) {
>> -        if (path == null || (!path.equals("") && !path.startsWith("/"))) {
>> +        boolean invalid = false;
>> +        if (path == null || path.equals("/")) {
>> +            path = "";
>
> this.path = "";
>
>> +            invalid = true;
>> +        } else if (!path.equals("") && !path.startsWith("/")) {
>>              this.path = "/" + path;
>> -            log.warn(sm.getString(
>> -                    "standardContext.pathInvalid", path, this.path));
>> +            invalid = true;
>>          } else {
>>              this.path = path;
>>          }
>> +        if (invalid) {
>> +            log.warn(sm.getString(
>> +                    "standardContext.pathInvalid", path, this.path));
>> +        }
>>          encodedPath = urlEncoder.encode(this.path);
>>          if (getName() == null) {
>>              setName(this.path);
>
>
> A number of test are failing at Gump.
> (They are failing at Buildbot as well, but none e-mails were received).
>
> E.g.
> Test org.apache.catalina.startup.TestListener FAILED
>
> and I see
>     [junit] 18-Nov-2014 01:21:53.447 WARNING [main]
> org.apache.catalina.core.StandardContext.setPath A context path must
> either be an empty string or start with a '/'. The path [] does not
> meet these criteria and has been changed to [null]

Fixed by r1640276

Remaining issues:
a) I think that context paths that end with "/" shall be prohibited as well.

b) Run the whole testsuite and fix tests to do not use "/" as context path.

E.g. org.apache.catalina.startup.TestListener now prints the warning

WARNING [main] org.apache.catalina.core.StandardContext.setPath A
context path must either be an empty string or start with a '/'. The
path [/] does not meet these criteria and has been changed to []

Its code does
        Context context = tomcat.addContext("/",
                System.getProperty("java.io.tmpdir"));

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1640089 - in /tomcat/tc8.0.x/trunk: ./ java/org/apache/catalina/core/StandardContext.java webapps/docs/changelog.xml

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-11-17 11:06 GMT+03:00  <ma...@apache.org>:
> Author: markt
> Date: Mon Nov 17 08:06:24 2014
> New Revision: 1640089
>
> URL: http://svn.apache.org/r1640089
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57216
> Catch "/" as an invalid setting for context path and improve handling of
> null values.
>
> Modified:
>     tomcat/tc8.0.x/trunk/   (props changed)
>     tomcat/tc8.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
>     tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml
>
> Propchange: tomcat/tc8.0.x/trunk/
> ------------------------------------------------------------------------------
>   Merged /tomcat/trunk:r1640088
>
> 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=1640089&r1=1640088&r2=1640089&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 Mon Nov 17 08:06:24 2014
> @@ -2008,13 +2008,20 @@ public class StandardContext extends Con
>       */
>      @Override
>      public void setPath(String path) {
> -        if (path == null || (!path.equals("") && !path.startsWith("/"))) {
> +        boolean invalid = false;
> +        if (path == null || path.equals("/")) {
> +            path = "";

this.path = "";

> +            invalid = true;
> +        } else if (!path.equals("") && !path.startsWith("/")) {
>              this.path = "/" + path;
> -            log.warn(sm.getString(
> -                    "standardContext.pathInvalid", path, this.path));
> +            invalid = true;
>          } else {
>              this.path = path;
>          }
> +        if (invalid) {
> +            log.warn(sm.getString(
> +                    "standardContext.pathInvalid", path, this.path));
> +        }
>          encodedPath = urlEncoder.encode(this.path);
>          if (getName() == null) {
>              setName(this.path);


A number of test are failing at Gump.
(They are failing at Buildbot as well, but none e-mails were received).

E.g.
Test org.apache.catalina.startup.TestListener FAILED

and I see
    [junit] 18-Nov-2014 01:21:53.447 WARNING [main]
org.apache.catalina.core.StandardContext.setPath A context path must
either be an empty string or start with a '/'. The path [] does not
meet these criteria and has been changed to [null]


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org