Author: markt
Date: Thu Apr 25 13:20:41 2013
New Revision: 1475755

URL: http://svn.apache.org/r1475755
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54801
and
https://issues.apache.org/bugzilla/show_bug.cgi?id=54821
Don't try to parse EL expressions if EL is disabled or inside scriptlets for 
JSP documents.
Based on patches by kkolinko

Added:
    tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx
      - copied unchanged from r1475750, 
tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx
    tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx
      - copied unchanged from r1475750, 
tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx
    tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx
      - copied unchanged from r1475750, 
tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx
    tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx
      - copied unchanged from r1475750, 
tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx
Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
    
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1475750

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java?rev=1475755&r1=1475754&r2=1475755&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 
Thu Apr 25 13:20:41 2013
@@ -488,7 +488,8 @@ class JspDocumentParser
             tagDependentNesting++;
         }
 
-        if (tagDependentNesting > 0) {
+        if (tagDependentNesting > 0 || pageInfo.isELIgnored() ||
+                current instanceof Node.ScriptingElement) {
             if (charBuffer.length() > 0) {
                 new Node.TemplateText(charBuffer.toString(), startMark, 
current);
             }

Modified: 
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java?rev=1475755&r1=1475754&r2=1475755&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java 
(original)
+++ 
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java 
Thu Apr 25 13:20:41 2013
@@ -22,9 +22,7 @@ import java.io.IOException;
 
 import javax.servlet.http.HttpServletResponse;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
+import org.junit.Assert;
 import org.junit.Test;
 
 import org.apache.catalina.startup.Tomcat;
@@ -47,7 +45,7 @@ public class TestJspDocumentParser exten
         int rc = getUrl("http://localhost:"; + getPort() +
                 "/test/bug47977.jspx", new ByteChunk(), null);
 
-        assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc);
+        Assert.assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc);
     }
 
     @Test
@@ -69,6 +67,48 @@ public class TestJspDocumentParser exten
         }
 
         // Should not fail
-        assertNull(e);
+        Assert.assertNull(e);
+    }
+
+    @Test
+    public void testBug54801() 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 bc = new ByteChunk();
+        int rc = getUrl("http://localhost:"; + getPort() +
+                "/test/bug5nnnn/bug54801a.jspx", bc, null);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+        bc.recycle();
+        rc = getUrl("http://localhost:"; + getPort() +
+                "/test/bug5nnnn/bug54801b.jspx", bc, null);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
     }
+
+    @Test
+    public void testBug54821() 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 bc = new ByteChunk();
+        int rc = getUrl("http://localhost:"; + getPort() +
+                "/test/bug5nnnn/bug54821a.jspx", bc, null);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+
+        bc.recycle();
+        rc = getUrl("http://localhost:"; + getPort() +
+                "/test/bug5nnnn/bug54821b.jspx", bc, null);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+   }
 }

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=1475755&r1=1475754&r2=1475755&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Apr 25 13:20:41 2013
@@ -100,6 +100,16 @@
         <bug>54802</bug>: Provide location information for exceptions thrown
         by JspDocumentParser. (kkolinko)
       </fix>
+      <fix>
+        <bug>54801</bug>: Do not attempt to parse text that looks like an EL
+        expressions inside a scriptlet in a JSP document because EL expressions
+        are not permitted in scriptlets. (kkolinko/markt)
+      </fix>
+      <fix>
+        <bug>54821</bug>: Do not attept to parse text that looks like an EL
+        expressions in a JSP document if EL expressions have been disabled.
+        (kkolinko/markt)  
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to