Author: markt Date: Fri Dec 28 13:08:01 2007 New Revision: 607331 URL: http://svn.apache.org/viewvc?rev=607331&view=rev Log: Fix bug 43914. URLs in location headers should be encoded. Patch provided by Ivan Todoroski.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=607331&r1=607330&r2=607331&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Fri Dec 28 13:08:01 2007 @@ -73,12 +73,6 @@ +1: markt,funkman, pero, yoavs -1: -* Fix http://issues.apache.org/bugzilla/show_bug.cgi?id=43914 - Location headers must be encoded. Patch provided by Ivan Todoroski. - http://svn.apache.org/viewvc?rev=606952&view=rev - +1: markt,funkman, pero, yoavs - -1: - * Fix http://issues.apache.org/bugzilla/show_bug.cgi?id=42503 ServletContext.getResourceAsStream returns stale data http://svn.apache.org/viewvc?rev=606994&view=rev Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=607331&r1=607330&r2=607331&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Fri Dec 28 13:08:01 2007 @@ -25,6 +25,7 @@ import org.apache.catalina.Globals; import org.apache.catalina.Wrapper; import org.apache.catalina.util.StringManager; +import org.apache.catalina.util.URLEncoder; import org.apache.coyote.ActionCode; import org.apache.coyote.Adapter; import org.apache.juli.logging.Log; @@ -101,6 +102,28 @@ StringManager.getManager(Constants.Package); + /** + * Encoder for the Location URL in HTTP redirects. + */ + protected static URLEncoder urlEncoder; + + + // ----------------------------------------------------- Static Initializer + + + /** + * The safe character set. + */ + static { + urlEncoder = new URLEncoder(); + urlEncoder.addSafeCharacter('-'); + urlEncoder.addSafeCharacter('_'); + urlEncoder.addSafeCharacter('.'); + urlEncoder.addSafeCharacter('*'); + urlEncoder.addSafeCharacter('/'); + } + + // -------------------------------------------------------- Adapter Methods @@ -452,7 +475,7 @@ // Possible redirect MessageBytes redirectPathMB = request.getMappingData().redirectPath; if (!redirectPathMB.isNull()) { - String redirectPath = redirectPathMB.toString(); + String redirectPath = urlEncoder.encode(redirectPathMB.toString()); String query = request.getQueryString(); if (request.isRequestedSessionIdFromURL()) { // This is not optimal, but as this is not very common, it Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=607331&r1=607330&r2=607331&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Fri Dec 28 13:08:01 2007 @@ -132,6 +132,10 @@ in the JSP with the error, use the SMAP info and the knowledge that for a scriptlet there is a one to one line mapping. (markt/jim) </fix> + <fix> + <bug>43914</bug>: URLs in location headers should be encoded. Patch + provided by Ivan Todoroski. (markt) + </fix> </changelog> </subsection> <subsection name="Webapps"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]