RE: IllegalArgumentException Exception in URLDecoder
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Kirk,
Looks like something like that was already done before and reverted by
Christian for reasons that aren't documented. The question is, if this
happens, what state is the "queryString" variable in? Does this meet url
encoding spec requirements? I'm no expert in this area. If anyone has
something to say about this, please speak up. In general, I think catching
the exception is probably a good thing even if it results in a string that
might not exactly match up with a the specs.
Here is what was commented out...
try {
queryString =
java.net.URLDecoder.decode(queryString, "UTF-8");
} catch (UnsupportedEncodingException e) {
System.out.println("Encoding Exception: "+e);
e.printStackTrace();
}
Here is what replaced it...
queryString = java.net.URLDecoder.decode(queryString);
Maybe it was reverted to much? There are still runtime exceptions that can
be thrown whether or not the method states one will be thrown. Also,
shouldn't we be using the non-deprecate method where we include the
encoding? It was done in the commented out code. What was the regression
that was seen?
Besides this, here is a case where the servlet-2.3 class
javax.servlet.http.HttpServletRequestWrapper could really help out. We
wouldn't even need to implement methods we really don't care about
including this one. I think we need to make the move to servlet-2.3 at
some point. Servlet-2.2 is very limiting.
Jake
At 02:11 PM 7/30/2003 +0200, you wrote:
>To reply to my own mail..
>
>I put a empty try/catch block around the respective code...
>and just ignored the exception when it arose..
>
>ok.. it's a hack.. but at least it's not fallin over now..
>
>try {
> queryString = java.net.URLDecoder.decode(queryString);
>} catch (Exception e) {}
>
>-----Original Message-----
>From: Kirk Daries [mailto:[email protected]]
>Sent: 30 July 2003 02:01
>To: [email protected]
>Subject: [Barracuda] IllegalArgumentException Exception in URLDecoder
>
>
>Hi Guys,
>
>I'm running into a exception...
>
>Basically... when I submit any text containing the symbol '%', it falls
>over.
>E.g.
>req.getQueryString() is: p_comments=Test+%25
>
>Which is "Test %"
>
>I've traced it to the HttpServletRequestWrapper class, line 398.
>
>Which says,
>queryString = java.net.URLDecoder.decode(queryString);
>
>I think the decode function is attempting to 'decode' the string a second
>time..
>
>Help?
>Regards
>KD
>
>java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in
>escape (%) pattern - For input string: "&p"
> at java.net.URLDecoder.decode(URLDecoder.java:168)
> at java.net.URLDecoder.decode(URLDecoder.java:82)
> at
>org.enhydra.barracuda.core.helper.servlet.HttpServletRequestWrapper.getParam
>eter(HttpServletRequestWrapper.java:398)
> at
>org.enhydra.barracuda.core.event.DefaultEventContext.restoreContext(DefaultE
>ventContext.java:224)
> at
>org.enhydra.barracuda.core.event.DefaultEventContext.(DefaultEventContext.ja
>va:74)
> at
>org.enhydra.barracuda.core.event.ApplicationGateway.handleDefaultExt(Applica
>tionGateway.java:398)
> at
>org.enhydra.barracuda.core.event.ApplicationGateway.handleDefault(Applicatio
>nGateway.java:234)
> at
>org.enhydra.barracuda.core.event.ApplicationGateway.doGet(ApplicationGateway
>.java:717)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
>FilterChain.java:247)
> at
>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
>ain.java:193)
> at
>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
>va:256)
> at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
>eNext(StandardPipeline.java:643)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
>va:191)
> at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
>eNext(StandardPipeline.java:643)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
>org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
> at
>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
>)
> at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
>eNext(StandardPipeline.java:643)
> at
>org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
>java:171)
> at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
>eNext(StandardPipeline.java:641)
> at
>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
>)
> at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
>eNext(StandardPipeline.java:641)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
>:174)
> at
>org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
>eNext(StandardPipeline.java:643)
> at
>org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at
>org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at
>org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at
>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
> at
>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
>ction(Http11Protocol.java:392)
> at
>org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
> at
>org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
>a:619)
> at java.lang.Thread.run(Thread.java:534)
>
>_______________________________________________
>Barracuda mailing list
>[email protected]
>http://barracudamvc.org/lists/listinfo/barracuda
>_______________________________________________
>Barracuda mailing list
>[email protected]
>http://barracudamvc.org/lists/listinfo/barracuda