This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 7e1deb26d4c56979e8eb9b2dc00c8e1f3e18405d Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Jun 18 16:54:45 2021 +0100 Fix BZ 65390 - revert code removal made in error https://bz.apache.org/bugzilla/show_bug.cgi?id=65390 The code is required and should not have been removed. Test case based one code provided by tk...@ai-ag.de --- java/org/apache/jasper/compiler/Generator.java | 4 ++++ test/org/apache/jasper/compiler/TestGenerator.java | 10 +++++++++ test/webapp/WEB-INF/tags/bug65390.tag | 20 ++++++++++++++++++ test/webapp/bug6nnnn/bug65390-empty.jsp | 17 +++++++++++++++ test/webapp/bug6nnnn/bug65390.jsp | 24 ++++++++++++++++++++++ webapps/docs/changelog.xml | 9 ++++++++ 6 files changed, 84 insertions(+) diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index 8305f6a..2ff636f 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -3299,6 +3299,10 @@ class Generator { boolean tmpIsFragment = isFragment; isFragment = true; String pushBodyCountVarSave = pushBodyCountVar; + if (pushBodyCountVar != null) { + // Use a fixed name for push body count, to simplify code gen + pushBodyCountVar = "_jspx_push_body_count"; + } visitBody(n); out = outSave; parent = tmpParent; diff --git a/test/org/apache/jasper/compiler/TestGenerator.java b/test/org/apache/jasper/compiler/TestGenerator.java index 49c700d..4589b8a 100644 --- a/test/org/apache/jasper/compiler/TestGenerator.java +++ b/test/org/apache/jasper/compiler/TestGenerator.java @@ -887,6 +887,16 @@ public class TestGenerator extends TomcatBaseTest { Assert.assertEquals(body.toString(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc); } + @Test + public void testBug65390() throws Exception { + getTomcatInstanceTestWebapp(false, true); + + ByteChunk body = new ByteChunk(); + int rc = getUrl("http://localhost:" + getPort() + "/test/bug6nnnn/bug65390.jsp", body, null); + + Assert.assertEquals(body.toString(), HttpServletResponse.SC_OK, rc); + } + private void doTestJsp(String jspName) throws Exception { doTestJsp(jspName, HttpServletResponse.SC_OK); } diff --git a/test/webapp/WEB-INF/tags/bug65390.tag b/test/webapp/WEB-INF/tags/bug65390.tag new file mode 100644 index 0000000..51d38c8 --- /dev/null +++ b/test/webapp/WEB-INF/tags/bug65390.tag @@ -0,0 +1,20 @@ +<%-- + 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 language="java" pageEncoding="UTF-8" body-content="scriptless"%> +<% +getJspBody().invoke(null); +%> \ No newline at end of file diff --git a/test/webapp/bug6nnnn/bug65390-empty.jsp b/test/webapp/bug6nnnn/bug65390-empty.jsp new file mode 100644 index 0000000..2f7bb10 --- /dev/null +++ b/test/webapp/bug6nnnn/bug65390-empty.jsp @@ -0,0 +1,17 @@ +<%-- + 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 uri="http://tomcat.apache.org/bugs" prefix="bugs" %> \ No newline at end of file diff --git a/test/webapp/bug6nnnn/bug65390.jsp b/test/webapp/bug6nnnn/bug65390.jsp new file mode 100644 index 0000000..59317ec --- /dev/null +++ b/test/webapp/bug6nnnn/bug65390.jsp @@ -0,0 +1,24 @@ +<%-- + 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. +--%> +<%@ include file="bug65390-empty.jsp" %> +<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> + +<bugs:TryCatchFinallyBodyTag> + <tags:bug65390> + <tags:bug65390>qqq</tags:bug65390> + </tags:bug65390> +</bugs:TryCatchFinallyBodyTag> \ No newline at end of file diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 7314cfe..28d98fc 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -177,6 +177,15 @@ </fix> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <fix> + <bug>65390</bug>: Correct a regression in the fix for <bug>65124</bug> + and restore code that was removed in error leading to JSP compilation + failures in some circumstances. (markt) + </fix> + </changelog> + </subsection> <subsection name="Web applications"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org