Bug 64373 - tag-file reference from .tld in /WEB-INF/classes/META-INF cannot be resolved
Summary: tag-file reference from .tld in /WEB-INF/classes/META-INF cannot be resolved
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 9.0.34
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-23 20:41 UTC by Karl von Randow
Modified: 2020-04-27 21:05 UTC (History)
0 users



Attachments
patch for TagLibraryInfoImpl (766 bytes, patch)
2020-04-23 20:41 UTC, Karl von Randow
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karl von Randow 2020-04-23 20:41:32 UTC
Created attachment 37195 [details]
patch for TagLibraryInfoImpl

When the Jar Scanner is configured with scanAllDirectories, TldScanner will load tag library descriptors in /WEB-INF/classes/META-INF/ (@see TldScanner.TldScannerCallback#scanWebInfClasses)

When a .tld references a tag-file, it MUST reference it as /META-INF/tags/blah.tag (attempting a relative path results in Illegal tag file path..., I guess that's a spec requirement)

e.g. /WEB-INF/classes/META-INF/tags.tld

<?xml version="1.0" encoding="UTF-8"?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
	version="2.0">
	<tlib-version>1.0</tlib-version>
	<short-name>tags</short-name>
	<tag-file>
		<name>bug</name>
		<path>/META-INF/tags/bug.tag</path>
	</tag-file>
</taglib>


A .tld living in /WEB-INF/classes referencing a tag-file in /META-INF/tags intends it to be loaded from /WEB-INF/classes/META-INF/tags in the same way that a .tag living in a jar is loaded from /META-INF inside the jar.

HOWEVER the tag-file is instead loaded from /META-INF/tags at the root of the webapp, which of course can't be found.

I think this should be resolved, as Tomcat appears to support .tlds in /WEB-INF/classes/META-INF. I also _think_ the solution is quite simple (hey sometimes it is!)...

TagLibraryInfoImpl#createTagFileInfo knows the path and whether it's in a jar or not, so it can "correct" the path to have /WEB-INF/classes in front. I've attached a patch for this change.

All the best,
Karl
Comment 1 Mark Thomas 2020-04-27 16:40:59 UTC
Looking at this now...

Yes, it is a spec requirement (JSP.8.4.1) that for tags packaged in a JAR the path must always start with "/META-INF/tags/..."
Comment 2 Mark Thomas 2020-04-27 19:48:13 UTC
Many thanks for the report and the patch. Your analysis looks to be spot on to me.

Fixed in:
- master for 10.0.0-M5 onwards
- 9.0.x for 9.0.35 onwards
- 8.5.x for 8.5.55 onwards
Comment 3 Karl von Randow 2020-04-27 21:05:25 UTC
That's fantastic, thank you very much Mark.