tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: SSI - Regular expression parsing
Date Mon, 01 Jul 2013 15:59:51 GMT
Hash: SHA256


On 6/28/13 7:40 PM, David Reitter wrote:
> I'm trying to use some SSI in 7.0.39 using SSIFilter.  The file is
> parsed, in principle, but whenever an IF expression with a certain
> regular expression is encountered, Tomcat seems to stop processing
> the file and will not return any contents after that (for the
> request).
> Example:
> My request is:
> http://...:8080/amt/file.html?year=234234
> The relevant portion of the file is:
> QS:<!--#echo var="QUERY_STRING" -->
> <!--#if expr="${QUERY_STRING} = /year=(.*)/" --> <!--ssi-comment:
> year found --> <!--#set var="year" value="$1" --> year: <!--#echo
> var="year" -->
> <!--#else --> not <!--ssi-comment: year NOT found --> <!--#set
> var="year" value="some" --> <!--#endif -->
> The response to the request is the beginning of the file, and then
> QS:year=2012
> After the "#if", nothing is encountered.

This is due to the error shown below. Thanks for locating it and
reporting it along with your post: often, we have to have a whole
round trip of "look at the longs", etc. before we can figure out
what's going on.

> Other IF statements work as expected - this seems to have to do
> with the regular expression.
> I have tried a number of variants, including $QUERY_STRING instead
> of ${...}. I find no error about this in the logs (I have set debug
> to 1 for the SSIFilter, but I'm not sure if I need to change
> anything else in logging properties.
> I tried simpler regular expressions.  The following
> <!--#if expr="${QUERY_STRING} = /year=/" -->
> Leads to the error below:
> java.lang.ClassCastException:
> org.apache.catalina.ssi.ExpressionParseTree$EqualNode cannot be
> cast to org.apache.catalina.ssi.ExpressionParseTree$StringNode 
> org.apache.catalina.ssi.ExpressionParseTree$CompareNode.compareBranches(
> org.apache.catalina.ssi.ExpressionParseTree.evaluateTree(
> org.apache.catalina.ssi.SSIConditional.process(
> org.apache.catalina.ssi.SSIFilter.doFilter(
> This occurs whenever the regular expression does not contain any
> parenthesis.  Is it even recognized/parsed as a regexp?
> Is this a bug, or is my syntax off?  I follow

Although it does not matter in this case (because the documentation is
pretty much identical), you should probably be reading this document

Can you provide a minimal test case as a WAR file: basically just the
META-INF/web.xml and a minimal SSI page to be processed?

It's very odd that the left-branch of the expression is being treated
as an "equal" node... my first guess at this point is that
${QUERY_STRING} is being interpreted /twice/ -- once as the variable
reference, then converted into its own value and possibly
re-interpreted? That would result in the expression "year=234234 =
/year=(.)/" which would make the left-expression "year=234234" which
would be an EqualNode. It really doesn't make any sense as people must
be doing this kind of thing all the time and we haven't heard any
complaints recently.

On the other hand, I think Tomcat's SSIs are quite rarely used.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Thunderbird -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message