Author: markt
Date: Thu Apr 25 13:16:45 2013
New Revision: 1475750

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

Added:
    tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx
    tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx
    tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx
    tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx
Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
    tomcat/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java?rev=1475750&r1=1475749&r2=1475750&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 
(original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java Thu Apr 
25 13:16:45 2013
@@ -484,7 +484,8 @@ class JspDocumentParser
             tagDependentNesting++;
         }
 
-        if (tagDependentNesting > 0) {
+        if (tagDependentNesting > 0 || pageInfo.isELIgnored() ||
+                current instanceof Node.ScriptingElement) {
             if (charBuffer.length() > 0) {
                 @SuppressWarnings("unused")
                 Node unused = new Node.TemplateText(

Modified: 
tomcat/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java?rev=1475750&r1=1475749&r2=1475750&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java 
(original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestJspDocumentParser.java Thu 
Apr 25 13:16:45 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);
+   }
 }

Added: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx?rev=1475750&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx (added)
+++ tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801a.jspx Thu Apr 25 13:16:45 
2013
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ 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.
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="2.0">
+<jsp:scriptlet><![CDATA[//
+  // ${foo}
+  out.println("Hello, world!!");
+]]></jsp:scriptlet>
+</jsp:root>
\ No newline at end of file

Added: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx?rev=1475750&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx (added)
+++ tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54801b.jspx Thu Apr 25 13:16:45 
2013
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ 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.
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="2.0">
+<jsp:scriptlet>
+  // ${foo}
+  out.println("Hello, world!!");
+</jsp:scriptlet>
+</jsp:root>
\ No newline at end of file

Added: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx?rev=1475750&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx (added)
+++ tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821a.jspx Thu Apr 25 13:16:45 
2013
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ 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.
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="2.0">
+<jsp:directive.page isELIgnored="true"/>
+${Hello, world!!}
+</jsp:root>
\ No newline at end of file

Added: tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx?rev=1475750&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx (added)
+++ tomcat/trunk/test/webapp-3.0/bug5nnnn/bug54821b.jspx Thu Apr 25 13:16:45 
2013
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ 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.
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="2.0">
+<jsp:directive.page isELIgnored="true"/>
+${Hello, world!!
+</jsp:root>
\ No newline at end of file



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

Reply via email to