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: [email protected]
For additional commands, e-mail: [email protected]