tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: svn commit: r1136231 - in /tomcat/trunk: java/org/apache/catalina/ssi/ExpressionParseTree.java webapps/docs/changelog.xml
Date Thu, 16 Jun 2011 12:08:31 GMT
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, markt@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;
> +                }
> +            }
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message