Add a test case for bug 48627
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 28 Jan 2010 23:35:39 +0000 (23:35 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 28 Jan 2010 23:35:39 +0000 (23:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@904305 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/jasper/compiler/TestParser.java [new file with mode: 0644]
test/webapp/WEB-INF/tags/echo-noel.tag [new file with mode: 0644]
test/webapp/bug48627.jsp [new file with mode: 0644]

diff --git a/test/org/apache/jasper/compiler/TestParser.java b/test/org/apache/jasper/compiler/TestParser.java
new file mode 100644 (file)
index 0000000..ec22984
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+package org.apache.jasper.compiler;
+
+import java.io.File;
+
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+public class TestParser extends TomcatBaseTest {
+    
+    public void testBug48627() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = 
+            new File("test/webapp");
+        // app dir is relative to server home
+        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+        
+        tomcat.start();
+
+        ByteChunk res = getUrl("http://localhost:" + getPort() +
+                "/test/bug48627.jsp");
+        
+        String result = res.toString();
+        
+        System.out.println(result);
+        
+        // Beware of the differences between escaping in JSP attributes and
+        // in Java Strings
+        assertTrue(result.indexOf("00-\\") > 0);
+        assertTrue(result.indexOf("01-\\") > 0);
+    }
+}
diff --git a/test/webapp/WEB-INF/tags/echo-noel.tag b/test/webapp/WEB-INF/tags/echo-noel.tag
new file mode 100644 (file)
index 0000000..9d6cc39
--- /dev/null
@@ -0,0 +1,19 @@
+<%--\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
+--%>\r
+<%@ tag%><%@\r
+attribute name="echo" type="java.lang.String" rtexprvalue="false"\r
+%><p>${echo}</p>
\ No newline at end of file
diff --git a/test/webapp/bug48627.jsp b/test/webapp/bug48627.jsp
new file mode 100644 (file)
index 0000000..54a79fa
--- /dev/null
@@ -0,0 +1,24 @@
+<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
+<%--
+ 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.
+--%>
+<html>
+  <head><title>Bug 46596 test case</title></head>
+  <body>
+    <tags:echo-noel echo="00-\\"/>
+    <tags:echo echo="01-\\"/>
+  </body>
+</html>
\ No newline at end of file