2012/7/9  <ma...@apache.org>:
> Author: markt
> Date: Mon Jul  9 19:11:54 2012
> New Revision: 1359342
>
> URL: http://svn.apache.org/viewvc?rev=1359342&view=rev
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53062
> Correctly handle case where redirect URL includes a query string (with test 
> cases)
>
> Modified:
>     tomcat/tc7.0.x/trunk/   (props changed)
>     tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java
>     tomcat/tc7.0.x/trunk/test/org/apache/catalina/connector/TestResponse.java
>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>
> Propchange: tomcat/tc7.0.x/trunk/
> ------------------------------------------------------------------------------
>   Merged /tomcat/trunk:r1359340
>
> Modified: 
> tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java?rev=1359342&r1=1359341&r2=1359342&view=diff
> ==============================================================================
> --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java 
> (original)
> +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/connector/Response.java Mon 
> Jul  9 19:11:54 2012
> @@ -1752,6 +1752,18 @@ public class Response
>       * Code borrowed heavily from CoyoteAdapter.normalize()
>       */
>      private void normalize(CharChunk cc) {
> +        // Strip query string first (doing it this way makes the logic a lot
> +        // simpler)
> +        int query = cc.indexOf('?');

Maybe it needs process anchors if query is absent. Something like this:
if (query < 0) {
query = cc.indexOf('#');
}

> +        char[] queryCC = null;
> +        if (query > -1) {
> +            queryCC = new char[cc.getEnd() - query];

java.util.Arrays.copyOfRange(char[],int from,int to) ?

> +            for (int i = query; i < cc.getEnd(); i++) {
> +                queryCC[i - query] = cc.charAt(i);
> +            }
> +            cc.setEnd(query);
> +        }
> +
>          if (cc.endsWith("/.") || cc.endsWith("/..")) {
>              try {
>                  cc.append('/');
> @@ -1810,6 +1822,15 @@ public class Response
>              cc.setEnd(end);
>              index = index2;
>          }
> +
> +        // Add the query string (if present) back in
> +        if (queryCC != null) {
> +            try {
> +                cc.append(queryCC, 0, queryCC.length);
> +            } catch (IOException ioe) {
> +                throw new IllegalArgumentException(ioe);
> +            }
> +        }
>      }
>
>      private void copyChars(char[] c, int dest, int src, int len) {
>

Best regards,
Konstantin Kolinko

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

Reply via email to