Author: markt
Date: Tue Jun 10 22:39:22 2014
New Revision: 1601785
URL: http://svn.apache.org/r1601785
Log:
Correctly parse two consecutive escaped single quotes when used in UEL
expression in a JSP.
Includes various unit tests that check the parsing of ${'\'\''}
Added:
tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp (with props)
Modified:
tomcat/trunk/java/org/apache/jasper/compiler/Parser.java
tomcat/trunk/test/org/apache/el/TestELEvaluation.java
tomcat/trunk/test/org/apache/el/TestELInJsp.java
tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java
tomcat/trunk/webapps/docs/changelog.xml
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=1601785&r1=1601784&r2=1601785&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Parser.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Parser.java Tue Jun 10
22:39:22 2014
@@ -751,7 +751,7 @@ class Parser implements TagConstants {
// XXX could move this logic to JspReader
last = reader.mark(); // XXX somewhat wasteful
currentChar = reader.nextChar();
- if (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
+ while (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
// skip character following '\' within quotes
reader.nextChar();
currentChar = reader.nextChar();
Modified: tomcat/trunk/test/org/apache/el/TestELEvaluation.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELEvaluation.java?rev=1601785&r1=1601784&r2=1601785&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestELEvaluation.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELEvaluation.java Tue Jun 10 22:39:22
2014
@@ -164,6 +164,11 @@ public class TestELEvaluation {
assertEquals("\"\\", evaluateExpression("${\"\\\"\\\\\"}"));
}
+ @Test
+ public void testMultipleEscaping() throws Exception {
+ assertEquals("''", evaluateExpression("${\"\'\'\"}"));
+ }
+
private void compareBoth(String msg, int expected, Object o1, Object o2){
int i1 = ELSupport.compare(o1, o2);
int i2 = ELSupport.compare(o2, o1);
Modified: tomcat/trunk/test/org/apache/el/TestELInJsp.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELInJsp.java?rev=1601785&r1=1601784&r2=1601785&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestELInJsp.java (original)
+++ tomcat/trunk/test/org/apache/el/TestELInJsp.java Tue Jun 10 22:39:22 2014
@@ -502,6 +502,26 @@ public class TestELInJsp extends TomcatB
}
+ @Test
+ public void testBug56612() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp");
+ // app dir is relative to server home
+ Context ctx = tomcat.addWebapp(null, "/test",
appDir.getAbsolutePath());
+
+ ctx.setResources(new StandardRoot(ctx));
+
+ tomcat.start();
+
+ ByteChunk res = getUrl("http://localhost:" + getPort() +
+ "/test/bug5nnnn/bug56612.jsp");
+
+ String result = res.toString();
+ Assert.assertTrue(result.contains("00-''"));
+ }
+
+
// Assertion for text contained with <p></p>, e.g. printed by tags:echo
private static void assertEcho(String result, String expected) {
assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0);
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=1601785&r1=1601784&r2=1601785&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java Tue Jun 10
22:39:22 2014
@@ -266,6 +266,13 @@ public class TestELParser {
}
+ @Test
+ public void testEscape11() throws JasperException {
+ // Bug 56612
+ doTestParser("${'\\'\\''}", "''");
+ }
+
+
private void doTestParser(String input, String expected) throws
JasperException {
ELException elException = null;
String elResult = null;
Added: tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp?rev=1601785&view=auto
==============================================================================
--- tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp (added)
+++ tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp Tue Jun 10 22:39:22 2014
@@ -0,0 +1,17 @@
+<%--
+ 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.
+--%>
+<p>00-${'\'\''}</p>
\ No newline at end of file
Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug56612.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=1601785&r1=1601784&r2=1601785&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Jun 10 22:39:22 2014
@@ -201,6 +201,10 @@
already been committed, do not clear the buffer of JspWriter, but flush
it. Thus it will become more clear where the error occurred. (kkolinko)
</update>
+ <fix>
+ <bug>56612</bug>: Correctly parse two consecutive escaped single quotes
+ when used in UEL expression in a JSP. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="WebSocket">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]