Author: markt Date: Tue Oct 29 13:00:00 2013 New Revision: 1536697 URL: http://svn.apache.org/r1536697 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55702 Fix loading of TLD when CATALINA_HOME contains spaces
Modified: tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java?rev=1536697&r1=1536696&r2=1536697&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java Tue Oct 29 13:00:00 2013 @@ -23,6 +23,8 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.Collection; import java.util.Enumeration; @@ -109,24 +111,32 @@ class TagLibraryInfoImpl extends TagLibr // resolveRelativeUri and/or getResourceAsStream don't seem to properly // handle relative paths when dealing when home and getDocBase are set // the following is a workaround until these problems are resolved. - private InputStream getResourceAsStream(String uri) + private InputStream getResourceAsStream(String uriAsString) throws FileNotFoundException { // Is uri absolute? - if (uri.startsWith("file:")) { - return new FileInputStream(new File(uri.substring(5))); + if (uriAsString.startsWith("file:")) { + URI uri; + try { + uri = new URI(uriAsString); + } catch (URISyntaxException e) { + FileNotFoundException fnfe = new FileNotFoundException(e.getMessage()); + fnfe.initCause(e); + throw fnfe; + } + return new FileInputStream(new File(uri)); } else { try { // see if file exists on the filesystem - String real = ctxt.getRealPath(uri); + String real = ctxt.getRealPath(uriAsString); if (real == null) { - return ctxt.getResourceAsStream(uri); + return ctxt.getResourceAsStream(uriAsString); } else { return new FileInputStream(real); } } catch (FileNotFoundException ex) { // if file not found on filesystem, get the resource through // the context - return ctxt.getResourceAsStream(uri); + return ctxt.getResourceAsStream(uriAsString); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org