[jboss-jira] [JBoss JIRA] (JBWEB-237) Use of File.toURL causes failures using JSP taglibs when path contains a space

Dennis Reed (JIRA) jira-events at lists.jboss.org
Thu Apr 19 17:32:18 EDT 2012


    [ https://issues.jboss.org/browse/JBWEB-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12685852#comment-12685852 ] 

Dennis Reed commented on JBWEB-237:
-----------------------------------

The current code is broken.  It produces invalid URLs.

The change that was made in EAP was to fix some broken use cases in file URL handling, which had a side effect of (correctly) throwing an error on invalid URLs that were missed before, including ones like this from JBoss Web.

All the patch does is encode characters that are not valid in a URL, so that the resulting URL is valid.
file.toURI().toURL() is the recommended method of correctly converting from a File to a URL.  See http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html#toURL%28%29

If this patch breaks anything else, that other code is already broken.
                
> Use of File.toURL causes failures using JSP taglibs when path contains a space
> ------------------------------------------------------------------------------
>
>                 Key: JBWEB-237
>                 URL: https://issues.jboss.org/browse/JBWEB-237
>             Project: JBoss Web
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: JBossWeb-2.1.12.GA
>            Reporter: James Livingston
>            Assignee: Remy Maucherat
>         Attachments: jbossweb-filetourl.diff
>
>
> org.apache.catalina.core.ApplicationContext.getResource() uses File.toURL(), which is deprecated in favour of File.toURI().toURL() because it does not escape characters correctly. With the FileURLConnection changes in EAP 5.1.2, this causes failures in the JSP taglib handling code if JBoss is installed into a path containing a space.
> java.net.URISyntaxException: Illegal character in path at index 16: file:/C:/Program Files/EnterprisePlatform-5.1.2/jboss-eap-5.1/jboss-as/server/ECARSPre/tmp/4naks-ed1hk0-gzfuvex8-1-gzfuw630-bu/ecp.war/WEB-INF/lib/ojdbc6.jar
> 	at java.net.URI$Parser.fail(Unknown Source)
> 	at java.net.URI$Parser.checkChars(Unknown Source)
> 	at java.net.URI$Parser.parseHierarchical(Unknown Source)
> 	at java.net.URI$Parser.parse(Unknown Source)
> 	at java.net.URI.<init>(Unknown Source)
> 	at java.net.URL.toURI(Unknown Source)
> 	at org.jboss.net.protocol.file.FileURLConnection.<init>(FileURLConnection.java:62)
> 	at org.jboss.net.protocol.file.Handler.openConnection(Handler.java:40)
> 	at java.net.URL.openConnection(Unknown Source)
> 	at org.jboss.web.tomcat.service.jasper.TagLibCache.processTldsInFileSystem(TagLibCache.java:266)
> 	at org.jboss.web.tomcat.service.jasper.TagLibCache.processTldsInFileSystem(TagLibCache.java:261)
> 	at org.jboss.web.tomcat.service.jasper.TagLibCache.init(TagLibCache.java:101)
> 	at org.jboss.web.tomcat.service.jasper.TagLibCache.getLocation(TagLibCache.java:83)
> 	at org.apache.jasper.JspCompilationContext.getTldLocation(JspCompilationContext.java:549)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list