Author: markt Date: Tue Nov 19 09:41:24 2013 New Revision: 1543356 URL: http://svn.apache.org/r1543356 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55792 EL 3.0 introduced the possibility of nested {...} sequences within EL expressions so update the JSP parser to handle them.
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Parser.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/Parser.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1543356&r1=1543355&r2=1543356&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Parser.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Parser.java Tue Nov 19 09:41:24 2013 @@ -736,14 +736,16 @@ class Parser implements TagConstants { } /* - * ELExpressionBody (following "${" to first unquoted "}") // XXX add formal - * production and confirm implementation against it, // once it's decided + * ELExpressionBody. Starts with "#{" or "${". Ends with "}".May contain + * quoted "{", "}", '{', or '}' and nested "{...}" */ private void parseELExpression(Node parent, char type) throws JasperException { start = reader.mark(); Mark last = null; - boolean singleQuoted = false, doubleQuoted = false; + boolean singleQuoted = false; + boolean doubleQuoted = false; + int nesting = 0; int currentChar; do { // XXX could move this logic to JspReader @@ -756,11 +758,20 @@ class Parser implements TagConstants { } if (currentChar == -1) err.jspError(start, "jsp.error.unterminated", type + "{"); - if (currentChar == '"' && !singleQuoted) + if (currentChar == '"' && !singleQuoted) { doubleQuoted = !doubleQuoted; - if (currentChar == '\'' && !doubleQuoted) + } else if (currentChar == '\'' && !doubleQuoted) { singleQuoted = !singleQuoted; - } while (currentChar != '}' || (singleQuoted || doubleQuoted)); + } else if (currentChar == '{' && !doubleQuoted && !singleQuoted) { + nesting++; + } else if (currentChar =='}' && !doubleQuoted && !singleQuoted) { + // Note: This also matches the terminating '}' at which point + // nesting will be set to -1 - hence the test for + // while (currentChar != '}' || nesting > -1 ||...) below + // to continue the loop until the final '}' is detected + nesting--; + } + } while (currentChar != '}' || singleQuoted || doubleQuoted || nesting > -1); @SuppressWarnings("unused") Node unused = new Node.ELExpression( --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org