Additional fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=49297
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Nov 2010 18:21:29 +0000 (18:21 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Nov 2010 18:21:29 +0000 (18:21 +0000)
Handle tag directives in a similar manner to page directives

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

java/org/apache/jasper/compiler/Parser.java
test/org/apache/jasper/compiler/TestParser.java
test/webapp-3.0/WEB-INF/tags/bug49297.tag [new file with mode: 0644]
test/webapp-3.0/bug49nnn/bug49297Tag.jsp [new file with mode: 0644]

index c9ef2f5..d7be14c 100644 (file)
@@ -572,7 +572,7 @@ class Parser implements TagConstants {
      * Attribute)*
      */
     private void parseTagDirective(Node parent) throws JasperException {
-        Attributes attrs = parseAttributes();
+        Attributes attrs = parseAttributes(true);
         Node.TagDirective n = new Node.TagDirective(attrs, start, parent);
 
         /*
index 0c2fe3b..8748915 100644 (file)
@@ -254,6 +254,25 @@ public class TestParser extends TomcatBaseTest {
         assertEquals(500, sc);
     }
 
+    public void testBug49297Tag() 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 = new ByteChunk();
+        int sc = getUrl("http://localhost:" + getPort() +
+                "/test/bug49nnn/bug49297Tag.jsp", res,
+                new HashMap<String,List<String>>());
+
+        assertEquals(200, sc);
+        assertEcho(res.toString(), "OK");
+    }
+
     /** Assertion for text printed by tags:echo */
     private static void assertEcho(String result, String expected) {
         assertTrue(result.indexOf("<p>" + expected + "</p>") > 0);
diff --git a/test/webapp-3.0/WEB-INF/tags/bug49297.tag b/test/webapp-3.0/WEB-INF/tags/bug49297.tag
new file mode 100644 (file)
index 0000000..8980737
--- /dev/null
@@ -0,0 +1,21 @@
+<%--\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+  contributor license agreements.  See the NOTICE file distributed with\r
+  this work for additional information regarding copyright ownership.\r
+  The ASF licenses this file to You under the Apache License, Version 2.0\r
+  (the "License"); you may not use this file except in compliance with\r
+  the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+--%><%@ tag import="java.util.List" import="java.util.ArrayList"%><%@\r
+tag body-content="empty" %><%\r
+    // Make sure the imports above do work\r
+    List<String> l = new ArrayList<String>();\r
+    l.add("OK");\r
+    %><p><%=l.get(0)%></p>
\ No newline at end of file
diff --git a/test/webapp-3.0/bug49nnn/bug49297Tag.jsp b/test/webapp-3.0/bug49nnn/bug49297Tag.jsp
new file mode 100644 (file)
index 0000000..f8a836e
--- /dev/null
@@ -0,0 +1,23 @@
+<%--
+ 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.
+--%>
+<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
+<html>
+  <head><title>Bug 49297 duplicate attribute test case</title></head>
+  <body>
+    <tags:bug49297 />
+  </body>
+</html>
\ No newline at end of file