tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Creighton Kirkendall <ckirkend...@hobsons-us.com>
Subject Not sure this is a BUG or a requirement by spec
Date Fri, 09 Aug 2002 18:03:21 GMT
I found where the bug is and I know how to fix it but I am not sure if it is
part of the http spec that you can not have "=" in a url parameter value;

I am trying to parse out a URL that has an embedded url in it, like so:
src=THIS_IS_JUST_A_TEST&url=/test/test.jsp?test=test&comments=TESTING

The problem comes when org.apache.catalina.util.RequestUtil. parseParameters
is called and it tries to parse the url.  Since it uses a case statement
that checks every character for a "=" and then assigns the left to a Key and
right to a value.  This causes a problem because it ignores the "url=" and
places a key in the map of "=/test/test.jsp?test" and a value of "test".
Should it not place "url" as the key and "/test/test.jsp?test=test" as the
value?  Below is a class that illustrates the problem. To fix this we need
to modify the case so that it knows when it state is in a key and when it is
in a value.



import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.catalina.util.ParameterMap;
import org.apache.catalina.util.RequestUtil;


public class parseParamsTest {

  /**
   * Initialize global variables
   */

  /**
   * Process the HTTP Get request
   */
    public static void main(String[] args) {
      try{
        String
query="src=THIS_IS_JUST_A_TEST&url=/test/test.jsp?test=test&comments=TESTING
";
        /* the above query should output the following Key values pairs
          src=HIS_IS_JUST_A_TEST
          url=/test/test.jsp?test=test
          comments=TESTING
        */

        ParameterMap tmp=new ParameterMap();
        RequestUtil.parseParameters(tmp,query,"ISO-8859-1");
        Set s=tmp.keySet();
        Iterator it=s.iterator();
        while(it.hasNext()){
          String key=(String)it.next();
          String[] values=(String[])tmp.get(key);
          for(int i=0; i<values.length;i++){
            System.out.println("Key:"+key+"\n\tValue:"+values[i]);
          }
        }

        /*current wrong output
          Key:/test/test.jsp?test   //why is this happing
              Value:test
          Key:comments
              Value:TESTING
          Key:src
              Value:THIS_IS_JUST_A_TEST
        */
      }catch(Exception e){
        e.printStackTrace();
      }
    }

  /**
   * Process the HTTP Post request
   */

}



Creighton Kirkendall

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


Mime
View raw message