Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48668
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 6 Mar 2010 21:03:14 +0000 (21:03 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 6 Mar 2010 21:03:14 +0000 (21:03 +0000)
Honor isELIgnored and isDeferredSyntaxAllowed in the Parser

Uncommented the test cases in TestParser/bug48668a.jsp that now are passing.
The ##12,13,16,17 remain commented, because they are still failing.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@919851 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/Parser.java
test/org/apache/jasper/compiler/TestParser.java
test/webapp/bug48668a.jsp

index 3955859..7cfb2bc 100644 (file)
@@ -1462,9 +1462,11 @@ class Parser implements TagConstants {
             err.jspError(reader.mark(), "jsp.error.no.scriptlets");
         } else if (reader.matches("<jsp:text")) {
             parseXMLTemplateText(parent);
-        } else if (reader.matches("${")) {
+        } else if (!pageInfo.isELIgnored() && reader.matches("${")) {
             parseELExpression(parent, '$');
-        } else if (reader.matches("#{")) {
+        } else if (!pageInfo.isELIgnored()
+                && !pageInfo.isDeferredSyntaxAllowedAsLiteral()
+                && reader.matches("#{")) {
             parseELExpression(parent, '#');
         } else if (reader.matches("<jsp:")) {
             parseStandardAction(parent);
@@ -1513,10 +1515,12 @@ class Parser implements TagConstants {
         } else if (reader.matches("<jsp:text")) {
             err.jspError(reader.mark(), "jsp.error.not.in.template",
                     "&lt;jsp:text");
-        } else if (reader.matches("${")) {
+        } else if (!pageInfo.isELIgnored() && reader.matches("${")) {
             err.jspError(reader.mark(), "jsp.error.not.in.template",
                     "Expression language");
-        } else if (reader.matches("#{")) {
+        } else if (!pageInfo.isELIgnored()
+                && !pageInfo.isDeferredSyntaxAllowedAsLiteral()
+                && reader.matches("#{")) {
             err.jspError(reader.mark(), "jsp.error.not.in.template",
                     "Expression language");
         } else if (reader.matches("<jsp:")) {
index 4d3654b..0a6b33b 100644 (file)
@@ -78,17 +78,17 @@ public class TestParser extends TomcatBaseTest {
         assertEcho(result, "32-Hello #{'foo}");
         assertEcho(result, "33-Hello #{'foo}");
         assertEcho(result, "34-Hello ${'foo}");
-        //assertEcho(result, "35-Hello ${'foo}");
+        assertEcho(result, "35-Hello ${'foo}");
         assertEcho(result, "36-Hello #{'foo}");
-        //assertEcho(result, "37-Hello #{'foo}");
+        assertEcho(result, "37-Hello #{'foo}");
         assertEcho(result, "40-Hello ${'foo}");
-        //assertEcho(result, "41-Hello ${'foo}");
-        //assertEcho(result, "42-Hello #{'foo}");
-        //assertEcho(result, "43-Hello #{'foo}");
+        assertEcho(result, "41-Hello ${'foo}");
+        assertEcho(result, "42-Hello #{'foo}");
+        assertEcho(result, "43-Hello #{'foo}");
         assertEcho(result, "50-Hello ${'foo}");
-        //assertEcho(result, "51-Hello ${'foo}");
-        //assertEcho(result, "52-Hello #{'foo}");
-        //assertEcho(result, "53-Hello #{'foo}");
+        assertEcho(result, "51-Hello ${'foo}");
+        assertEcho(result, "52-Hello #{'foo}");
+        assertEcho(result, "53-Hello #{'foo}");
     }
 
     public void testBug48668b() throws Exception {
index 94a9442..b95958a 100644 (file)
     <p>32-<tags:bug48668 noexpr="Hello #{'foo}"/></p>
     <p>33-Hello <tags:bug48668 noexpr="#{'foo}"/></p>
     <p>34-<tags:bug48668><jsp:attribute name="noexpr">Hello ${'foo}</jsp:attribute></tags:bug48668></p>
-<%--<p>35-Hello <tags:bug48668><jsp:attribute name="noexpr">${'foo}</jsp:attribute></tags:bug48668></p>--%>
+    <p>35-Hello <tags:bug48668><jsp:attribute name="noexpr">${'foo}</jsp:attribute></tags:bug48668></p>
     <p>36-<tags:bug48668><jsp:attribute name="noexpr">Hello #{'foo}</jsp:attribute></tags:bug48668></p>
-<%--<p>37-Hello <tags:bug48668><jsp:attribute name="noexpr">#{'foo}</jsp:attribute></tags:bug48668></p>--%>
+    <p>37-Hello <tags:bug48668><jsp:attribute name="noexpr">#{'foo}</jsp:attribute></tags:bug48668></p>
 
     <p>40-<tags:bug48668><jsp:attribute name="fragment">Hello ${'foo}</jsp:attribute></tags:bug48668></p>
     <p>41-Hello <tags:bug48668><jsp:attribute name="fragment">${'foo}</jsp:attribute></tags:bug48668></p>
     <p>42-<tags:bug48668><jsp:attribute name="fragment">Hello #{'foo}</jsp:attribute></tags:bug48668></p>
-<%--<p>43-Hello <tags:bug48668><jsp:attribute name="fragment">#{'foo}</jsp:attribute></tags:bug48668></p>--%>
+    <p>43-Hello <tags:bug48668><jsp:attribute name="fragment">#{'foo}</jsp:attribute></tags:bug48668></p>
 
     <p>50-<tags:bug48668>Hello ${'foo}</tags:bug48668></p>
     <p>51-Hello <tags:bug48668>${'foo}</tags:bug48668></p>
     <p>52-<tags:bug48668>Hello #{'foo}</tags:bug48668></p>
-<%--<p>53-Hello <tags:bug48668>#{'foo}</tags:bug48668></p>--%>
+    <p>53-Hello <tags:bug48668>#{'foo}</tags:bug48668></p>
   </body>
 </html>