This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new f159cd54c1 Correctly handle tag libraries packaged in JARs in a WAR deployment f159cd54c1 is described below commit f159cd54c1bfc198797eccbac5fb2d5e40811139 Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Mar 13 11:18:27 2024 +0000 Correctly handle tag libraries packaged in JARs in a WAR deployment This fixes a JSP TCK test. It is likely a long standing bug but wasn't detected as, prior to Jakarta EE 11, the TCK provided web applications were unpacked prior to test execution. --- java/org/apache/jasper/compiler/TagLibraryInfoImpl.java | 8 ++++++++ res/checkstyle/org-import-control.xml | 1 + webapps/docs/changelog.xml | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java index d7f1ab4847..fa247aaade 100644 --- a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java +++ b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java @@ -45,6 +45,7 @@ import jakarta.servlet.jsp.tagext.ValidationMessage; import org.apache.jasper.JasperException; import org.apache.jasper.JspCompilationContext; import org.apache.tomcat.Jar; +import org.apache.tomcat.util.buf.UriUtil; import org.apache.tomcat.util.descriptor.tld.TagFileXml; import org.apache.tomcat.util.descriptor.tld.TagXml; import org.apache.tomcat.util.descriptor.tld.TaglibXml; @@ -268,6 +269,13 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { URL url = null; try { url = ctxt.getResource(uri); + /* + * When the TLD cache is built for a TLD contained within a JAR within a WAR, the jar form of the URL is + * used for any nested JAR. + */ + if (url.getProtocol().equals("war") && uri.endsWith(".jar")) { + url = UriUtil.warToJar(url); + } } catch (Exception ex) { err.jspError("jsp.error.tld.unable_to_get_jar", uri, ex.toString()); } diff --git a/res/checkstyle/org-import-control.xml b/res/checkstyle/org-import-control.xml index 29ea88f313..b6d877321d 100644 --- a/res/checkstyle/org-import-control.xml +++ b/res/checkstyle/org-import-control.xml @@ -112,6 +112,7 @@ <allow pkg="org.apache.jasper"/> <allow pkg="org.apache.juli"/> <allow pkg="org.apache.tomcat" exact-match="true"/> + <allow pkg="org.apache.tomcat.util.buf"/> <allow pkg="org.apache.tomcat.util.descriptor"/> <allow pkg="org.apache.tomcat.util.scan"/> <allow pkg="org.apache.tomcat.util.security"/> diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index a5290dd74c..d26fdd6813 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -195,6 +195,11 @@ <code>IllegalStateException</code> on code paths where there was a subsequent attempt to obtain a <code>Writer</code>. (markt) </fix> + <fix> + Correctly handle the case where a tag library is packaged in a JAR file + and the web application is deployed as a WAR file rather than an + unpacked directory. (markt) + </fix> </changelog> </subsection> <subsection name="Cluster"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org