Issue 183: LimitActionFactoryImpl attempts to decode parameters that have already been decoded
Status:  Done
Owner: ----
Closed:  Apr 2009
Reported by bgo...@e1b.org, Mar 4, 2009
Here is the code from LimitActionFactoryImpl:

        for (Object param : parameters.keySet()) {
            String parameter = (String) param;
            if (parameter.startsWith(prefixId + Action.FILTER.toParam())) {
                String value = LimitUtils.getValue(parameters.get(parameter));
                try {
                    value = decode(value, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                if (StringUtils.isNotBlank(value)) {
                    String property = StringUtils.substringAfter(parameter,
prefixId + Action.FILTER.toParam());
                    Filter filter = new Filter(property, value);
                    filterSet.addFilter(filter);
                }
            }
        }

I entered a value like this into the filter: %-26-% (for a "LIKE" query)

I got this exception:

[3/4/09 10:00:08:906 EST] 0000003a WebApp        E   [Servlet
Error]-[JMesaSupportServlet]: java.lang.IllegalArgumentException:
URLDecoder: Incomplete trailing escape (%) pattern
	at java.net.URLDecoder.decode(URLDecoder.java:180)
	at
org.jmesa.limit.LimitActionFactoryImpl.getFilterSet(LimitActionFactoryImpl.java:92)
	at org.jmesa.limit.LimitFactoryImpl.createLimit(LimitFactoryImpl.java:120)
	at org.jmesa.facade.TableFacadeImpl.getLimit(TableFacadeImpl.java:182)

Is there a reason why LimitActionFactory is trying to decode the parameters
there, when they should have already been decoded by the app server?  If
so, can we just catch the IllegalArgumentException and drive on with the
raw value if this case occurs?

Or am I doing something wrong?

Thanks.
Mar 4, 2009
Project Member #1 jeff.johnston.mn@gmail.com
That particular code may have originally come over from the eXtremeTable. If you take
that out does it still work fine? Your right that the parameters will be decoded by
the app server. If you able to test it out let me know what you find. I can do some
testing myself this week. I want to validate that things like the worksheet still
work fine.

Mar 9, 2009
Project Member #2 jeff.johnston.mn@gmail.com
If you get the chance to test this out I could do another release within a couple weeks.
Status: Accepted
Mar 9, 2009
#3 bgo...@e1b.org
Reply, ok, I'll give it a shot.  Sorry I didn't reply the first time, been a little 
busy.
Mar 9, 2009
Project Member #4 jeff.johnston.mn@gmail.com
I totally understand. I am investigating converting over our Oracle database to MySQL
so I am just updating JMesa as I have needs or get patches...
Mar 11, 2009
#5 bgo...@e1b.org
Just tested this by commenting out the try/catch block show above, and it seems to
work fine.
Mar 11, 2009
Project Member #6 jeff.johnston.mn@gmail.com
The change makes sense to me as well. I will take out those lines of code and update
trunk tonight. I will also be doing another release within a week.

Thanks for testing it out!
Mar 11, 2009
Project Member #7 jeff.johnston.mn@gmail.com
The change is on the trunk now...it will be released in the next few days.
Apr 5, 2009
Project Member #8 jeff.johnston.mn@gmail.com
Part of the 2.4.2 release.
Status: Done