From: markt Date: Sun, 10 Jan 2010 12:44:31 +0000 (+0000) Subject: Add tests for a bug found whilst reviewing the ELParser X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5eed5fccf3cb5a619f5425ae5490d6bf7092f269;p=tomcat7.0 Add tests for a bug found whilst reviewing the ELParser git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@897627 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/org/apache/el/TestELEvaluation.java b/test/org/apache/el/TestELEvaluation.java index 6b0ee57ae..ad1619844 100644 --- a/test/org/apache/el/TestELEvaluation.java +++ b/test/org/apache/el/TestELEvaluation.java @@ -21,6 +21,7 @@ import java.io.File; import java.lang.reflect.Method; import java.util.Date; +import javax.el.ELException; import javax.el.ValueExpression; import javax.el.FunctionMapper; @@ -115,10 +116,27 @@ public class TestELEvaluation extends TestCase { // Inspired by work on bug 45451, comments from kkolinko on the dev // list and looking at the spec to find some edge cases - // '\' is only an escape character inside a StringLiteral + // The only characters that can be escaped inside a String literal + // are \ " and '. # and $ are not escaped inside a String literal. assertEquals("\\", evaluateExpression("${'\\\\'}")); assertEquals("\\", evaluateExpression("${\"\\\\\"}")); + assertEquals("\\\"'$#", evaluateExpression("${'\\\\\\\"\\'$#'}")); + assertEquals("\\\"'$#", evaluateExpression("${\"\\\\\\\"\\'$#\"}")); + + // Trying to quote # or $ should throw an error + Exception e = null; + try { + evaluateExpression("${'\\$'}"); + } catch (ELException el) { + e = el; + } + assertNotNull(e); + assertEquals("\\$", evaluateExpression("${'\\\\$'}")); + assertEquals("\\\\$", evaluateExpression("${'\\\\\\\\$'}")); + + + // Can use ''' inside '"' when quoting with '"' and vice versa without // escaping assertEquals("\\\"", evaluateExpression("${'\\\\\"'}"));