You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Creighton Kirkendall <ck...@hobsons-us.com> on 2002/08/09 20:03:21 UTC
Not sure this is a BUG or a requirement by spec
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Not sure this is a BUG or a requirement by spec
Posted by Tim Funk <fu...@joedog.org>.
This is a bug on your part. The RFC for URI (rfc2396) states that = must
be encoded as well as some other choice characters.
See section 2.2:
http://www.ietf.org/rfc/rfc2396.txt
Creighton Kirkendall wrote:
> 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
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>