struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Horváth, Ákos Péter (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (WW-3956) (nearly) silent failure of filter initialization if struts.action.excludePattern contains invalid regexp
Date Fri, 04 Jan 2013 09:06:13 GMT

    [ https://issues.apache.org/jira/browse/WW-3956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13543713#comment-13543713
] 

Horváth, Ákos Péter edited comment on WW-3956 at 1/4/13 9:05 AM:
-----------------------------------------------------------------

I don't get anything, not with devmode and not without. I use a recompiled, but otherways
unmodified struts-core-2.3.8 with maven.

Today (CET) I will try with the original distributed binary version, and send you a minimalexample.

About the docs:

Yes, I found this, but this wasn't enough. For example, I wasn't able to find out, that ^
and $ is needed in the regexp or not. I wasn't able to find out, that it is case sensitive
or not. I wasn't able to find out, that the "(a|b|c)"-like regexp matching works or not. I
wasn't able to find out, how can I quote: is a single backslash enough, or I need more (because
of we are in xml). And finally, I wasn't able to find out, that single "."-s are needed to
be quoted if I won't an any-char match.

The first misleading, which a struts newbie finds, is that "excludePattern" is about patterns,
but really they are working with regexps. My first try was a "*.js,*.css". And it will silently
fail, because as regular expression these are invalid, and because of the previous problem.
(Which I will yet investigate)

Finally, I could investigate all of these, and now everything works, but this required a deep
dig in struts source.

And google is full with misleading information about this, and with bad examples. Google for
+"struts.action.excludePattern" and you will see. Imho you need a very clear correction.
                
      was (Author: hap):
    I don't get anything, not with devmode and not without. I use a recompiled, but otherways
unmodified struts-core-2.3.8 with maven.

Today (CET) I will try with the original distributed binary version, and send you a minimalexample.

About the docs:

Yes, I found this, but this wasn't enough. For example, I wasn't able to find out, that ^
and $ is needed in the regexp or not. I wasn't able to find out, that it is case sensitive
or not. I wasn't able to find out, that the "(a|b|c)"-like regexp matching works or not. I
wasn't able to find out, how can I quote: is a single backslash enough, or I need more (because
of we are in xml). And finally, I wasn't able to find out, that single "."-s are needed to
be quoted if I won't an any-char match.

The first misleading, which a struts newbie finds, is that "excludePattern" is about patterns,
but really they are working with regexps. My first try was a "*.js,*.css". And it will silently
fail, because as regular expression these are invalid, and because of the previous problem.
(Which I will yet investigate)

Finally, I could investigate all of these, and now everything works, but this needed a deep
investigation of the source of the struts core.

And google is full with misleading information about this, and with bad examples. Google for
+"struts.action.excludePattern" and you will see.
                  
> (nearly) silent failure of filter initialization if struts.action.excludePattern contains
invalid regexp
> --------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3956
>                 URL: https://issues.apache.org/jira/browse/WW-3956
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Dispatch Filter
>    Affects Versions: 2.3.8
>         Environment: all
>            Reporter: Horváth, Ákos Péter
>             Fix For: 2.3.9
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> If the struts.action.excludePatterns constant contains an invalid regexp (for example,
it begins with a "*"), the dispatcher can't initialize, but only an "Error filterStart" message
will be logged, and the web app won't work. Imho, the expected behavior were a stack trace
or a more descriptive error message.
> The cause of the problem: the buildExcludedPatternList() method of org.apache.struts2.dispatcher.ng.InitOperations
builds a compiled pattern list of the comma-separated patterns given in this constant with
java.util.regex.Pattern.compile() . This emits an IllegalArgumentException or a PatternSyntaxException,
if invalid regexp is given, but this exception somewhere silently disappears on his way to
the log.
> ---------------
> I suggest to make a minimal example in the documentation:
> ".*\.(css|js|gif|png|jpg|html)$" or "^/static/"
> is what most developer want from this constant. For me took hours to investigate this.
Googling for "struts.action.excludePattern" reveals a lot of confusion about this, too. The
greatest source of the confusion is that it isn't clear, and isn't anywhere documented, which
is the exact regexp syntax here to apply. For example: pattern matching or regular expression,
"^" and "$" are valid or not, they are needed or not, "." matches only "." or any character,
etc. I think, the original inaccuracy was committed by sun, when they named a class as "Pattern",
which operates with regexps. What you here can do, is a single-line minimal-example in the
doc, which will explain everything.
> Thank you,
> PH

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message