Bug 48956

Summary: SSI regular expressions not working
Product: Tomcat 6 Reporter: Albert Tumanov <altumano>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: 6.0.26   
Target Milestone: default   
Hardware: PC   
OS: Mac OS X 10.4   

Description Albert Tumanov 2010-03-22 11:48:29 UTC
I was trying to use Tomcat SSI filter:

http://tomcat.apache.org/tomcat-6.0-doc/ssi-howto.html

While it generally works, I have discovered that SSI regular expressions are not supported.
As much as I can see from tomcat source code, this feature is just not implemented.

For example, those expressions always return "did not match":

<!--#if expr="abc = /abc/" -->matches<!--#else -->did not match<!--#endif -->

<!--#if expr="abc = /[a-z]/" -->matches<!--#else -->did not match<!--#endif -->

This bug is a showstopper for me, because in my application I need SSI regular expressions support.
Comment 1 Mark Thomas 2010-03-22 17:11:42 UTC
Patches for enhancement requests are always welcome
Comment 2 Mark Thomas 2011-06-15 22:43:30 UTC
Fixed in 7.0.x and will be included in 7.0.17 onwards.

I don't see this being back-ported to 6.0.x or 5.5.x.
Comment 3 Maribel B. 2012-04-27 18:54:18 UTC
Hi, I found a bug working with Tomcat, SSI and regular expression that is still unresolved and my work is essential for proper operation:

For example:
<!--#set var="aux" value="aa12" -->
<!--#if expr="$aux=/^aa([a-zA-Z0-9\-_]*)/" -->
        <!--#set var="aux2" value="$1" -->
<!--#endif -->

Resulting value:<!--#echo var="aux2" -->


In a html file works correctly, but when working on Tomcat, a complex regular expression fails, and the page returns nothing from it.

Regards and await your response.
Comment 4 Konstantin Kolinko 2012-06-07 18:24:09 UTC
(In reply to comment #3)
> Hi, I found a bug working with Tomcat, SSI and regular expression that is
> still unresolved and my work is essential for proper operation:

I do not understand your description. What do you mean by "fails" and what do you mean by "returns nothing"?

Please provide:

1. What are the steps to reproduce your problem

2. What is the actual behaviour that you are observing.

3. What do you expect the correct behaviour to be.

=======================================
By the way:

1. The actual implementation Regexp matching is in
 org/apache/catalina/ssi/ExpressionParseTree.java,
 in method compareBranches()

2. The feature was implemented by r1136231 and r1136399
3. r1136399 was result of discussion in "Re: r1136231" thread on dev@. In archives:
http://markmail.org/message/g6ba77x7abkhibnn
http://marc.info/?t=130817798400003&r=1&w=2

4. If you can provide a patch for ExpressionParseTree#compareBranches(), it would be faster.
Comment 5 Konstantin Kolinko 2012-06-08 12:16:47 UTC
(In reply to comment #3)
I think I understood what you are asking for.
It is a separate issue, so I filed it separately -> bug 53387

I am re-closing this issue as FIXED.