Author: markt Date: Tue Jun 10 22:46:55 2014 New Revision: 1601787 URL: http://svn.apache.org/r1601787 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56612 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/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug56612.jsp - copied unchanged from r1601785, tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1601785 Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1601787&r1=1601786&r2=1601787&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java Tue Jun 10 22:46:55 2014 @@ -745,7 +745,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/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java?rev=1601787&r1=1601786&r2=1601787&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java Tue Jun 10 22:46:55 2014 @@ -120,6 +120,7 @@ public class NioChannel implements ByteC */ @Override public int write(ByteBuffer src) throws IOException { + System.out.println(Thread.currentThread().isInterrupted()); return sc.write(src); } Modified: tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java?rev=1601787&r1=1601786&r2=1601787&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java Tue Jun 10 22:46:55 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/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java?rev=1601787&r1=1601786&r2=1601787&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java Tue Jun 10 22:46:55 2014 @@ -488,6 +488,24 @@ public class TestELInJsp extends TomcatB } + @Test + public void testBug56612() throws Exception { + Tomcat tomcat = getTomcatInstance(); + + File appDir = new File("test/webapp-3.0"); + // app dir is relative to server home + tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); + + 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/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java?rev=1601787&r1=1601786&r2=1601787&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java Tue Jun 10 22:46:55 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; Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1601787&r1=1601786&r2=1601787&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jun 10 22:46:55 2014 @@ -112,6 +112,10 @@ <bug>56561</bug>: Avoid <code>NoSuchElementException</code> while handling attributes with empty string value. (violetagg) </fix> + <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: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org