Details
-
Bug
-
Resolution: Done
-
Major
-
JBoss AS7 7.2.0.Final, 8.0.0.CR1
-
None
Description
ServletContext.getResource() returns an invalid URL if the file name contains # characters.
Example:
URL url = servletContext.getResource("/file#1.txt");
The resulting URL object will be spitted at the # character like this:
url.toString(): jndi:/default-host/tomcat-url-bug/file#1.txt url.getPath(): /default-host/tomcat-url-bug/file url.getRef(): 1.txt
Calling url.openStream() will throw a FileNotFoundException.
This is a known Tomcat issue fixed in 7.0.28.
References:
https://issues.apache.org/bugzilla/show_bug.cgi?id=53257
https://issues.apache.org/bugzilla/show_bug.cgi?id=51584
According to the discussion on the Tomcat issue tracker, there are also problems for other characters which have special meaning in URLs.