You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Musachy Barroso <mu...@gmail.com> on 2009/02/09 17:41:20 UTC

Re: ParametersInterceptor - isAccepted / acceptedParamNames won't work with a comma seperated list of param names

Yes, that was broken and was fixed in 2.1 to:

protected boolean isAccepted(String paramName) {
        if (!this.acceptParams.isEmpty()) {
            for (Pattern pattern : acceptParams) {
                Matcher matcher = pattern.matcher(paramName);
                if (matcher.matches()) {
                    return true;
                }
            }
        }
        return acceptedPattern.matcher(paramName).matches();
    }

as a workaround, you can use a regex that matches all the values:

"(id|anotherid)"

musachy

On Mon, Feb 9, 2009 at 11:04 AM, Torsten Krah
<tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> I wonder if someone faced this behavior before, wheter this is "known" or
> wanted.
> XWork ParametersInterceptor Code:
>
>    protected boolean isAccepted(String paramName) {
>        if (!this.acceptedParams.isEmpty()) {
>            for (Pattern pattern : acceptedParams) {
>                Matcher matcher = pattern.matcher(paramName);
>                if (!matcher.matches()) {
>                    return false;
>                }
>            }
>        }
>        return acceptedPattern.matcher(paramName).matches();
>    }
>
> Taking a param list like "id, anotherid" which are both "accepted" and
> configured in my interceptor stack.
> But using the Code above, none of them will ever be accepted, because the
> pattern list is traversed and matched against the actual parameter.
>
> first run: id matches id -> OK
> second run: anotherid does not match id -> FALSE
>
> Although the Pattern list does contain a pattern which may result in a "true"
> match, false will be returned if there are more than 2 patterns in the list
> (order doesnt matter).
>
> My parameter is not set.
> Is this indented behavior? Or something wrong here?
>
> thx
>
> Torsten
>
> PS: Using struts 2.0.11.x, XWork 2.0.5
>
> --
> Bitte senden Sie mir keine Word- oder PowerPoint-Anhänge.
> Siehe http://www.gnu.org/philosophy/no-word-attachments.de.html
>
> Really, I'm not out to destroy Microsoft. That will just be a
> completely unintentional side effect."
>        -- Linus Torvalds
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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