** What happens if PatternSyntaxException is thrown? (bad regex is passed in) While it is a RuntimeException - i'd assume you'd want to log.warn(with the regex) and return -1;
-Tim On 6/15/2011 6:44 PM, ma...@apache.org wrote: Modified: tomcat/trunk/java/org/apache/catalina/ssi/ExpressionParseTree.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ssi/ExpressionParseTree.java?rev=1136231&r1=1136230&r2=1136231&view=diff ============================================================================== @@ -350,6 +351,21 @@ public class ExpressionParseTree { protected int compareBranches() { String val1 = ((StringNode)left).getValue(); String val2 = ((StringNode)right).getValue(); + + int val2Len = val2.length(); + if (val2Len > 1 && val2.charAt(0) == '/' && + val2.charAt(val2Len - 1) == '/') { + // Treat as a regular expression + String expr = val2.substring(1, val2Len - 1); + Pattern pattern = Pattern.compile(expr); + // Regular expressions will only ever be used with EqualNode + // so return zero for equal and non-zero for not equal + if (pattern.matcher(val1).find()) { + return 0; + } else { + return -1; + } + }