You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/06/18 22:43:58 UTC
svn commit: r1603621 - in /tomcat/trunk:
java/org/apache/jasper/compiler/ELParser.java
test/org/apache/jasper/compiler/TestELParser.java
test/org/apache/jasper/compiler/TestParser.java
test/webapp/bug5nnnn/bug56334and56561.jspx webapps/docs/changelog.xml
Author: markt
Date: Wed Jun 18 20:43:58 2014
New Revision: 1603621
URL: http://svn.apache.org/r1603621
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56334#c15
Handle potential whitespace around input.
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java
tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java
tomcat/trunk/test/webapp/bug5nnnn/bug56334and56561.jspx
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=1603621&r1=1603620&r2=1603621&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java Wed Jun 18 20:43:58 2014
@@ -294,30 +294,34 @@ public class ELParser {
int len = input.length();
char quote = 0;
int lastAppend = 0;
+ int start = 0;
+ int end = len;
- if (len > 1) {
+ // 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;
@@ -329,9 +333,6 @@ public class ELParser {
return input;
} else {
output.append(input.substring(lastAppend, len));
- if (quote != 0) {
- output.append(quote);
- }
return output.toString();
}
}
Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java?rev=1603621&r1=1603620&r2=1603621&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java Wed Jun 18 20:43:58 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/trunk/test/org/apache/jasper/compiler/TestParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java?rev=1603621&r1=1603620&r2=1603621&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java Wed Jun 18 20:43:58 2014
@@ -417,6 +417,13 @@ public class TestParser extends TomcatBa
Assert.assertTrue(result, result.contains("<set data-value=\"05c##{>hello<\"/>"));
Assert.assertTrue(result, result.contains("05x:<set data-value=\"\"/>"));
Assert.assertTrue(result, result.contains("<set xmlns:foo=\"urn:06a\\bar\\baz\"/>"));
+ Assert.assertTrue(result, result.contains("07a:<set data-value=\"\\?resize\"/>"));
+ Assert.assertTrue(result, result.contains("07b:<set data-content=\"\\?resize=.+\"/>"));
+ Assert.assertTrue(result, result.contains("07c:<set data-content=\"\\?resize=.+\"/>"));
+ Assert.assertTrue(result, result.contains("07d:<set data-content=\"false\"/>"));
+ Assert.assertTrue(result, result.contains("07e:<set data-content=\"false\"/>"));
+ Assert.assertTrue(result, result.contains("07f:<set data-content=\"\\\'something\'\"/>"));
+ /* Assert.assertTrue(result, result.contains("07g:<set data-content=\"\\\'something\'\"/>")); */
}
/** Assertion for text printed by tags:echo */
Modified: tomcat/trunk/test/webapp/bug5nnnn/bug56334and56561.jspx
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug56334and56561.jspx?rev=1603621&r1=1603620&r2=1603621&view=diff
==============================================================================
--- tomcat/trunk/test/webapp/bug5nnnn/bug56334and56561.jspx (original)
+++ tomcat/trunk/test/webapp/bug5nnnn/bug56334and56561.jspx Wed Jun 18 20:43:58 2014
@@ -18,7 +18,8 @@
<jsp:root version="2.3"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:jsp="http://java.sun.com/JSP/Page"
- xmlns:c="http://java.sun.com/jsp/jstl/core">
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<jsp:directive.page contentType="text/plain; charset=ISO-8859-1"/>
@@ -56,4 +57,12 @@
<!-- Test 6: nonTaglibXmlnsAttributes on a Node.UninterpretedTag -->
<set xmlns:foo="urn:06a\bar\baz" />
+ <!-- 7. Tests for bug 56334 comment 15 -->
+ 07a:<set data-value="${'\\?resize'}" />
+ 07b:<set data-content="${fn:escapeXml('\\?resize=.+')}" />
+ 07c:<set data-content="${fn:escapeXml( '\\?resize=.+')}" />
+ 07d:<set data-content="${fn:contains(some_value,'\\?resize=.+')}" />
+ 07e:<set data-content="${fn:contains(some_value, '\\?resize=.+')}" />
+ 07f:<set data-content="${fn:toLowerCase('\\\'someThing\'')}" />
+ 07g:<set data-content="${fn:toLowerCase( '\\\'someThing\'')}" />
</jsp:root>
\ No newline at end of file
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1603621&r1=1603620&r2=1603621&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 18 20:43:58 2014
@@ -209,6 +209,10 @@
</subsection>
<subsection name="Jasper">
<changelog>
+ <fix>
+ <bug>56334#c15</bug>: Fix a regression in EL parsing when quoted string
+ follows a whitespace. (kkolinko/markt)
+ </fix>
<update>
<bug>56543</bug>: Update to the Eclipse JDT Compiler 4.4RC4 to pick up
some fixes for Java 8 support. (markt/kkolinko)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org