This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 459c12275f Correctly handle tag libraries packaged in JARs in a WAR 
deployment
459c12275f is described below

commit 459c12275f40f999a106a7c5d2ff9ce22e0e9d96
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 2023550efc..170305cf0d 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 4f3e7a605d..c77301a8fa 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -139,6 +139,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="Other">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to