tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1136399 - /tomcat/trunk/java/org/apache/catalina/ssi/ExpressionParseTree.java
Date Thu, 16 Jun 2011 12:28:02 GMT
Author: markt
Date: Thu Jun 16 12:28:01 2011
New Revision: 1136399

URL: http://svn.apache.org/viewvc?rev=1136399&view=rev
Log:
Align SSI regexp handling with htttpd

Modified:
    tomcat/trunk/java/org/apache/catalina/ssi/ExpressionParseTree.java

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=1136399&r1=1136398&r2=1136399&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ssi/ExpressionParseTree.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ssi/ExpressionParseTree.java Thu Jun 16 12:28:01
2011
@@ -21,6 +21,7 @@ import java.text.ParseException;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 /**
  * Represents a parsed expression.
  * 
@@ -357,13 +358,18 @@ public class ExpressionParseTree {
                     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()) {
+                try {
+                    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;
+                    }
+                } catch (PatternSyntaxException pse) {
+                    ssiMediator.log("Invalid expression: " + expr, pse);
                     return 0;
-                } else {
-                    return -1;
                 }
             }
             return val1.compareTo(val2);



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


Mime
View raw message