Bug 66409 - Loading Resources with Blanks in Path Fails
Summary: Loading Resources with Blanks in Path Fails
Status: RESOLVED DUPLICATE of bug 66388
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.70
Hardware: All All
: P2 major (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-04 09:21 UTC by Michael Ratzenböck
Modified: 2023-01-04 09:39 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Ratzenböck 2023-01-04 09:21:49 UTC
Since Tomcat 9.0.70, the following problem occurs.

When loading resources (e.g. a font from a jar file) an URISyntaxException is thrown, if the URI is not valid. However, this also includes URLs which contain blanks, meaning that loading resources that contain a blank, the resource cannot be loaded since the determined URL is null.

E.g. Tomcat 7.0.69 was able to load the following resource: "MS Sans Serif.ttf", whereas Tomcat 7.0.70 is not able to load it anymore, with the following debug message:

04-Jan-2023 09:56:22.921 FEIN [http-nio-7000-exec-12] org.apache.catalina.webresources.AbstractArchiveResource.getURL Unable to determine a URL for the resource [jar:file:/C:/iheroot/ihe-main-4.2.x/client-web/module/target/ihe.module/WEB-INF/lib/ihe-jasperreports-fonts-4.5.1.jar!/net/sf/jasperreports/fonts/mssansserif/MS Sans Serif.ttf]
	java.net.URISyntaxException: Illegal character in opaque part at index 108: jar:file:/C:/module/WEB-INF/lib/ihe-jasperreports-fonts-4.5.1.jar!/net/sf/jasperreports/fonts/mssansserif/MS Sans Serif.ttf
		at java.net.URI$Parser.fail(URI.java:2847)
		at java.net.URI$Parser.checkChars(URI.java:3020)
		at java.net.URI$Parser.parse(URI.java:3057)
		at java.net.URI.<init>(URI.java:588)
		at org.apache.catalina.webresources.AbstractArchiveResource.getURL(AbstractArchiveResource.java:144)
		at org.apache.catalina.webresources.CachedResource.getURL(CachedResource.java:348)
		at org.apache.catalina.loader.WebappClassLoaderBase.findResource(WebappClassLoaderBase.java:956)
		at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1078)

Some investigation on our side showed that org.apache.cataline.webresources.AbstractArchiveResource#getURL() has changed from version 7.0.69 to 7.0.70. Instead of using the java.net.URL directly, java.net.URI(url).toURL() is used now. The problem is, that the URL is not encoded properly.

The hardware and OS should not influence this bug.
Comment 1 Remy Maucherat 2023-01-04 09:39:12 UTC

*** This bug has been marked as a duplicate of bug 66388 ***