atom feed3 messages in org.apache.tomcat.devRe: svn commit: r1136231 - in /tomcat...
FromSent OnAttachments
mar...@apache.orgJun 15, 2011 3:44 pm 
Tim FunkJun 16, 2011 3:57 am 
Mark ThomasJun 16, 2011 5:08 am 
Subject:Re: svn commit: r1136231 - in /tomcat/trunk: java/org/apache/catalina/ssi/ExpressionParseTree.java webapps/docs/changelog.xml
From:Mark Thomas (mar@apache.org)
Date:Jun 16, 2011 5:08:31 am
List:org.apache.tomcat.dev

On 16/06/2011 11:57, Tim Funk wrote:

** 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;

Not sure. Swallowing the error and assuming a non-match seems bad too. A syntax error in a JSP page isn't going to be that forgiving. Time to ask "What would httpd do?".

Wasn't expecting that. It returns a match. I'll amend my patch to do the same.

Mark

-Tim

On 6/15/2011 6:44 PM, mar@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; + } + }