tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r1142959 - in /tomcat/trunk: java/org/apache/catalina/connector/Response.java webapps/docs/changelog.xml
Date Tue, 05 Jul 2011 10:08:01 GMT
Author: rjung
Date: Tue Jul  5 10:08:00 2011
New Revision: 1142959

URL: http://svn.apache.org/viewvc?rev=1142959&view=rev
Log:
Fix response.encodeURL() for the special case of
an absolute URL with no path segment (http://name).

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/Response.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/connector/Response.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Response.java?rev=1142959&r1=1142958&r2=1142959&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Response.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Response.java Tue Jul  5 10:08:00 2011
@@ -1198,8 +1198,10 @@ public class Response
         String absolute = toAbsolute(url);
         if (isEncodeable(absolute)) {
             // W3c spec clearly said 
-            if (url.equalsIgnoreCase("")){
+            if (url.equalsIgnoreCase("")) {
                 url = absolute;
+            } else if (url.equals(absolute) && !hasPath(url)) {
+                url += '/';
             }
             return (toEncoded(url, request.getSessionInternal().getIdInternal()));
         } else {
@@ -1648,6 +1650,21 @@ public class Response
 
 
     /**
+     * Determine if an absolute URL has a path component
+     */
+    private boolean hasPath(String uri) {
+        int pos = uri.indexOf("://");
+        if (pos < 0) {
+            return false;
+        }
+        pos = uri.indexOf('/', pos + 3);
+        if (pos < 0) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
      * Determine if a URI string has a <code>scheme</code> component.
      */
     private boolean hasScheme(String uri) {

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1142959&r1=1142958&r2=1142959&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Jul  5 10:08:00 2011
@@ -74,6 +74,10 @@
         <bug>51473</bug>: Fix concatenation of values in
         <code>SecurityConfig.setSecurityProperty()</code>. (kkolinko)
       </fix>
+      <fix>
+        Fix response.encodeURL() for the special case of an absolute URL
+        with no path segment (http://name). (rjung)
+      </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


Mime
View raw message