From 5157a60aaf95b11bd3f438555c2a06a4cd710e6c Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 28 Jan 2010 23:35:39 +0000 Subject: [PATCH] Add a test case for bug 48627 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@904305 13f79535-47bb-0310-9956-ffa450edef68 --- test/org/apache/jasper/compiler/TestParser.java | 50 +++++++++++++++++++++++++ test/webapp/WEB-INF/tags/echo-noel.tag | 19 ++++++++++ test/webapp/bug48627.jsp | 24 ++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 test/org/apache/jasper/compiler/TestParser.java create mode 100644 test/webapp/WEB-INF/tags/echo-noel.tag create mode 100644 test/webapp/bug48627.jsp diff --git a/test/org/apache/jasper/compiler/TestParser.java b/test/org/apache/jasper/compiler/TestParser.java new file mode 100644 index 000000000..ec2298433 --- /dev/null +++ b/test/org/apache/jasper/compiler/TestParser.java @@ -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 index 000000000..9d6cc394d --- /dev/null +++ b/test/webapp/WEB-INF/tags/echo-noel.tag @@ -0,0 +1,19 @@ +<%-- + 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. +--%> +<%@ tag%><%@ +attribute name="echo" type="java.lang.String" rtexprvalue="false" +%>

${echo}

\ No newline at end of file diff --git a/test/webapp/bug48627.jsp b/test/webapp/bug48627.jsp new file mode 100644 index 000000000..54a79fac4 --- /dev/null +++ b/test/webapp/bug48627.jsp @@ -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. +--%> + + Bug 46596 test case + + + + + \ No newline at end of file -- 2.11.0