Author: markt Date: Wed Dec 6 14:50:42 2017 New Revision: 1817298 URL: http://svn.apache.org/viewvc?rev=1817298&view=rev Log: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=61854 When using sets and/or maps in EL expressions, ensure that Jasper correctly parses the expression. Patch provided by Ricardo Martin Camarero.
Added: tomcat/trunk/test/webapp/bug6nnnn/bug61854.jsp (with props) Modified: tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java tomcat/trunk/test/org/apache/el/TestELInJsp.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java?rev=1817298&r1=1817297&r2=1817298&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java Wed Dec 6 14:50:42 2017 @@ -106,11 +106,17 @@ public class ELParser { ELexpr = new ELNode.Nodes(); curToken = null; prevToken = null; + int openBraces = 0; while (hasNext()) { curToken = nextToken(); if (curToken instanceof Char) { if (curToken.toChar() == '}') { - break; + openBraces--; + if (openBraces < 0) { + break; + } + } else if (curToken.toChar() == '{') { + openBraces++; } buf.append(curToken.toString()); } else { Modified: tomcat/trunk/test/org/apache/el/TestELInJsp.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELInJsp.java?rev=1817298&r1=1817297&r2=1817298&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/el/TestELInJsp.java (original) +++ tomcat/trunk/test/org/apache/el/TestELInJsp.java Wed Dec 6 14:50:42 2017 @@ -510,6 +510,16 @@ public class TestELInJsp extends TomcatB } + @Test + public void testBug61854a() throws Exception { + getTomcatInstanceTestWebapp(true, true); + + ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug6nnnn/bug61854.jsp"); + String result = res.toString(); + assertEcho(result, "01-OK"); + } + + // Assertion for text contained with <p></p>, e.g. printed by tags:echo private static void assertEcho(String result, String expected) { Assert.assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0); Added: tomcat/trunk/test/webapp/bug6nnnn/bug61854.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug6nnnn/bug61854.jsp?rev=1817298&view=auto ============================================================================== --- tomcat/trunk/test/webapp/bug6nnnn/bug61854.jsp (added) +++ tomcat/trunk/test/webapp/bug6nnnn/bug61854.jsp Wed Dec 6 14:50:42 2017 @@ -0,0 +1,24 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--%> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> +<html> + <head><title>Bug 60431 test case</title></head> + <body> + <<tags:echo echo="0${ map = {'1':'2', 'a':'b'}; fn:length(map['a']) }-OK"/> + </body> +</html> \ No newline at end of file Propchange: tomcat/trunk/test/webapp/bug6nnnn/bug61854.jsp ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1817298&r1=1817297&r2=1817298&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Dec 6 14:50:42 2017 @@ -58,6 +58,15 @@ </fix> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <fix> + <bug>61854</bug>: When using sets and/or maps in EL expressions, ensure + that Jasper correctly parses the expression. Patch provided by Ricardo + Martin Camarero. (markt) + </fix> + </changelog> + </subsection> <subsection name="Coyote"> <changelog> <add> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org