You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/04/27 18:34:50 UTC
[tomcat] branch master updated: Fix bz 64373. Ensure tag file
unpacked from WAR can be found.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 224fb6c Fix bz 64373. Ensure tag file unpacked from WAR can be found.
224fb6c is described below
commit 224fb6c06528180213b6af28b28dee44029565d7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Apr 27 19:34:25 2020 +0100
Fix bz 64373. Ensure tag file unpacked from WAR can be found.
Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=64373
Patch provided by Karl von Randow
---
.../apache/jasper/compiler/TagLibraryInfoImpl.java | 8 ++++++
.../jasper/compiler/TestTagLibraryInfoImpl.java | 15 +++++++++++
test/webapp/WEB-INF/classes/META-INF/bug64373.tld | 31 ++++++++++++++++++++++
.../WEB-INF/classes/META-INF/tags/bug64373.tag | 17 ++++++++++++
test/webapp/bug6nnnn/bug64373.jsp | 23 ++++++++++++++++
webapps/docs/changelog.xml | 5 ++++
6 files changed, 99 insertions(+)
diff --git a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
index 60a9522..4a284a8 100644
--- a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
+++ b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
@@ -313,6 +313,7 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants {
tagXml.hasDynamicAttributes());
}
+ @SuppressWarnings("null") // Impossible for path to be null at warning
private TagFileInfo createTagFileInfo(TagFileXml tagFileXml, Jar jar) throws JasperException {
String name = tagFileXml.getName();
@@ -325,6 +326,13 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants {
err.jspError("jsp.error.tagfile.illegalPath", path);
}
+ if (jar == null && path.startsWith("/META-INF/tags")) {
+ // This is a tag file that was packaged in a JAR that has been
+ // unpacked into /WEB-INF/classes (probably by an IDE). Adjust the
+ // path accordingly.
+ path = "/WEB-INF/classes" + path;
+ }
+
TagInfo tagInfo =
TagFileProcessor.parseTagFileDirectives(parserController, name, path, jar, this);
return new TagFileInfo(name, path, tagInfo);
diff --git a/test/org/apache/jasper/compiler/TestTagLibraryInfoImpl.java b/test/org/apache/jasper/compiler/TestTagLibraryInfoImpl.java
index 262da60..65c0ca5 100644
--- a/test/org/apache/jasper/compiler/TestTagLibraryInfoImpl.java
+++ b/test/org/apache/jasper/compiler/TestTagLibraryInfoImpl.java
@@ -40,4 +40,19 @@ public class TestTagLibraryInfoImpl extends TomcatBaseTest {
Assert.assertEquals(HttpServletResponse.SC_OK, rc);
}
+
+ /*
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=64373
+ */
+ @Test
+ public void testTldFromExplodedWar() throws Exception {
+ getTomcatInstanceTestWebapp(false, true);
+
+ ByteChunk res = new ByteChunk();
+
+ int rc = getUrl("http://localhost:" + getPort() +
+ "/test/bug6nnnn/bug64373.jsp", res, null);
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+ }
+
}
diff --git a/test/webapp/WEB-INF/classes/META-INF/bug64373.tld b/test/webapp/WEB-INF/classes/META-INF/bug64373.tld
new file mode 100644
index 0000000..5fcf458
--- /dev/null
+++ b/test/webapp/WEB-INF/classes/META-INF/bug64373.tld
@@ -0,0 +1,31 @@
+<?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.
+--><taglib xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
+ version="2.1">
+ <tlib-version>1.0</tlib-version>
+ <short-name>bug64373</short-name>
+ <uri>http://tomcat.apache.org/bug64373</uri>
+
+ <tag-file>
+ <name>bug64373</name>
+ <path>/META-INF/tags/bug64373.tag</path>
+ </tag-file>
+
+</taglib>
\ No newline at end of file
diff --git a/test/webapp/WEB-INF/classes/META-INF/tags/bug64373.tag b/test/webapp/WEB-INF/classes/META-INF/tags/bug64373.tag
new file mode 100644
index 0000000..14c713e
--- /dev/null
+++ b/test/webapp/WEB-INF/classes/META-INF/tags/bug64373.tag
@@ -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.
+--%><%@ tag %><%@
+tag body-content="empty" %><p>OK</p>
\ No newline at end of file
diff --git a/test/webapp/bug6nnnn/bug64373.jsp b/test/webapp/bug6nnnn/bug64373.jsp
new file mode 100644
index 0000000..f7fe445
--- /dev/null
+++ b/test/webapp/bug6nnnn/bug64373.jsp
@@ -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 uri="http://tomcat.apache.org/bug64373" prefix="bugs" %>
+<html>
+ <head><title>Bug 64373 test case</title></head>
+ <body>
+ <bugs:bug64373 />
+ </body>
+</html>
\ No newline at end of file
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9f868fa..7058fd2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -127,6 +127,11 @@
Add more descriptive error message in DefaultServlet for SC_NOT_FOUND.
(michaelo)
</add>
+ <fix>
+ <bug>64373</bug>: When a tag file is packaged in a WAR and then that WAR
+ is unpacked in <code>/WEB-INF/classes</code> ensure that the tag file
+ can still be found. Patch provided by Karl von Randow. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org