Author: markt Date: Tue Sep 30 13:13:30 2014 New Revision: 1628430 URL: http://svn.apache.org/r1628430 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56334#c15 Fix a regression in EL parsing when quoted string follows a whitespace.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java tomcat/tc6.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1628430&r1=1628429&r2=1628430&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Tue Sep 30 13:13:30 2014 @@ -28,12 +28,6 @@ None PATCHES PROPOSED TO BACKPORT: [ New proposals should be added at the end of the list ] -* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56334#c15 - Fix a regression in EL parsing when quoted string follows a whitespace. - http://people.apache.org/~markt/patches/2014-06-18-bug56334%23c15-tc6-v1.patch - +1: markt, kkolinko, remm - -1: - * Assert that MappingData object is empty before performing mapping work. It is backport of r1604663 Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java?rev=1628430&r1=1628429&r2=1628430&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ELParser.java Tue Sep 30 13:13:30 2014 @@ -291,30 +291,34 @@ public class ELParser { int len = input.length(); char quote = 0; int lastAppend = 0; - - if (len > 1) { + int start = 0; + int end = len; + + // Look to see if the value is quoted + String trimmed = input.trim(); + int trimmedLen = trimmed.length(); + if (trimmedLen > 1) { // Might be quoted - quote = input.charAt(0); + quote = trimmed.charAt(0); if (quote == '\'' || quote == '\"') { - if (input.charAt(len - 1) != quote) { + if (trimmed.charAt(trimmedLen - 1) != quote) { throw new IllegalArgumentException(Localizer.getMessage( "org.apache.jasper.compiler.ELParser.invalidQuotesForStringLiteral", input)); } - lastAppend = 1; - len--; + start = input.indexOf(quote) + 1; + end = start + trimmedLen - 2; } else { quote = 0; } } StringBuilder output = null; - for (int i = lastAppend; i < len; i++) { + for (int i = start; i < end; i++) { char ch = input.charAt(i); if (ch == '\\' || ch == quote) { if (output == null) { output = new StringBuilder(len + 20); - output.append(quote); } output.append(input.substring(lastAppend, i)); lastAppend = i + 1; @@ -326,9 +330,6 @@ public class ELParser { return input; } else { output.append(input.substring(lastAppend, len)); - if (quote != 0) { - output.append(quote); - } return output.toString(); } } Modified: tomcat/tc6.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java?rev=1628430&r1=1628429&r2=1628430&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java (original) +++ tomcat/tc6.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java Tue Sep 30 13:13:30 2014 @@ -92,6 +92,12 @@ public class TestELParser { @Test + public void testFunction05() throws JasperException { + doTestParser("${do:it(x, '\\\\y',z)}", null); + } + + + @Test public void testCompound01() throws JasperException { doTestParser("1${'foo'}1", "1foo1"); } Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1628430&r1=1628429&r2=1628430&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Tue Sep 30 13:13:30 2014 @@ -78,6 +78,10 @@ <subsection name="Jasper"> <changelog> <fix> + <bug>56334</bug>: Fix a regression in EL parsing when quoted string + follows a whitespace. (markt) + </fix> + <fix> <bug>56560</bug>: Fix NoClassDefFoundError when using Jasper Ant task defined by <code>catalina-tasks.xml</code> file. Patch provided by M Gemmell. (kkolinko) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org