You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Felix Shnir <fe...@betteradvertising.com> on 2010/02/18 16:35:21 UTC

Bug / Edge case

Hi all, decided to post the recent issue I discovered with struts 2 here
before submitting a jira bug -- need to determine if this was a bug to begin
with :)

Essentially, we have all actions of struts 2 mapped to * -- no extension.
 One of the action handlers uses the following path:
www.blah.com/web-app/action/parameter.  This setup works well in most cases
except when the parameter we use contains a dot (.), example:
www.blah.com/web-app/action/parameter.com.  For some reason, the
org.apache.struts2.dispatcher.mapper.DefaultActionMapper will return null
mapping for this.  After a brief look into the source, I've noticed that
dropExtension method contains code that determines if this is right mapping
or not based on an empty extension and this code:

                int index = name.lastIndexOf('.');
                if (index == -1 || name.indexOf('/', index) >= 0) {
                    return name;
                }

Lines 467-470.

I've modified this for our local struts installation, tho this needs to be
resolved in the core build, I think the dropExtension only when extensions
are defined in the struts.xml or mapping.  Also, what was the case for this
item to begin with?  Thanks!

Felix.

Re: Bug / Edge case

Posted by Philipp Leusmann <ph...@rwth-aachen.de>.
Hi Felix,

I also found this bug (?) some weeks ago. I think it belong to this jira issue, where I also wrote my concerns: <https://issues.apache.org/jira/browse/WW-3381>

An easy fix to bypass this, if you do not want to compile struts, is to override the ActionMapper with your own implementation of dropExtension(String, ActionMapping) and set it in struts.properties.

Regards,
 Philipp

Am 18.02.2010 um 16:35 schrieb Felix Shnir:

> Hi all, decided to post the recent issue I discovered with struts 2 here
> before submitting a jira bug -- need to determine if this was a bug to begin
> with :)
> 
> Essentially, we have all actions of struts 2 mapped to * -- no extension.
> One of the action handlers uses the following path:
> www.blah.com/web-app/action/parameter.  This setup works well in most cases
> except when the parameter we use contains a dot (.), example:
> www.blah.com/web-app/action/parameter.com.  For some reason, the
> org.apache.struts2.dispatcher.mapper.DefaultActionMapper will return null
> mapping for this.  After a brief look into the source, I've noticed that
> dropExtension method contains code that determines if this is right mapping
> or not based on an empty extension and this code:
> 
>                int index = name.lastIndexOf('.');
>                if (index == -1 || name.indexOf('/', index) >= 0) {
>                    return name;
>                }
> 
> Lines 467-470.
> 
> I've modified this for our local struts installation, tho this needs to be
> resolved in the core build, I think the dropExtension only when extensions
> are defined in the struts.xml or mapping.  Also, what was the case for this
> item to begin with?  Thanks!
> 
> Felix.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org