This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 262780

Summary: [82cat] [regression] Paths with %20 should be converted to spaces
Product: javaee Reporter: brettryan <brettryan>
Component: JSP ParserAssignee: issues@javaee <issues>
Status: STARTED ---    
Severity: normal CC: markiewb
Priority: P4 Keywords: PATCH_AVAILABLE
Version: 8.2   
Hardware: PC   
OS: Mac OS X   
Issue Type: DEFECT Exception Reporter:
Attachments: Patch replacing dangerous File.toURL() to Utilities.toURI(File).toURL()

Description brettryan 2016-07-12 12:53:50 UTC
This issue has been identified where spaces exist in the install path while opening jsp content. Upon opening log messages are produced where about illegal characters. Investigating this reveals that while the path is printed with a space, the actual string contents of the URL contains %20. This may potentially be a bug in the JSP support, however; it would be great if org.openide.util.BaseUtilities#toURI(java.io.File) recovered from this by detecting a scheme of 'file' and replacing occurrences of '%20' with a space.


Steps to Reproduce
==================
1. Have the IDE in a path with a space and start.
2. Open a web project
3. Open a JSP with a taglib reference such as "<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>"


Actual Behaviour
================
IDE seems to function fine (albeit am I missing functionality?), though exceptions of those attached are spat out.


Desired Behaviour
=================
Recover from exceptions and not litter messages.



Product Version: NetBeans IDE Dev (Build 20160712-16457b922100)
Java: 1.8.0_92; Java HotSpot(TM) 64-Bit Server VM 25.92-b14
Runtime: Java(TM) SE Runtime Environment 1.8.0_92-b14
System: Mac OS X version 10.11.4 running on x86_64; UTF-8; en_AU (nb)
User directory: /Users/bryan/Development/netcat/netbeans ide/nbbuild/testuserdir
Cache directory: /Users/bryan/Development/netcat/netbeans ide/nbbuild/testuserdir/var/cache



     [exec] INFO [org.netbeans.modules.masterfs.filebasedfs.FileBasedURLMapper]: URL=file:/Users/bryan/Development/netcat/netbeans ide/nbbuild/netbeans/enterprise/docs/jstl11-doc.zip
     [exec] java.net.URISyntaxException: Illegal character in path at index 45: file:/Users/bryan/Development/netcat/netbeans ide/nbbuild/netbeans/enterprise/docs/jstl11-doc.zip
     [exec] 	at java.net.URI$Parser.fail(URI.java:2848)
     [exec] 	at java.net.URI$Parser.checkChars(URI.java:3021)
     [exec] 	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
     [exec] 	at java.net.URI$Parser.parse(URI.java:3053)
     [exec] 	at java.net.URI.<init>(URI.java:588)
     [exec] 	at java.net.URL.toURI(URL.java:946)
     [exec] [catch] at org.netbeans.modules.masterfs.filebasedfs.FileBasedURLMapper.getFileObjects(FileBasedURLMapper.java:98)
     [exec] 	at org.netbeans.modules.masterfs.MasterURLMapper.getFileObjects(MasterURLMapper.java:65)
     [exec] 	at org.openide.filesystems.URLMapper.findFileObject(URLMapper.java:213)
     [exec] 	at org.openide.filesystems.JarArchiveRootProvider.isArchiveFile(JarArchiveRootProvider.java:78)
     [exec] 	at org.openide.filesystems.FileUtil.getArchiveRoot(FileUtil.java:1861)
     [exec] 	at org.netbeans.modules.web.core.syntax.JspSyntaxSupport.initHelp(JspSyntaxSupport.java:782)
     [exec] 	at org.netbeans.modules.web.core.syntax.JspSyntaxSupport.initCompletionData(JspSyntaxSupport.java:853)
     [exec] 	at org.netbeans.modules.web.core.syntax.JspSyntaxSupport.getAllTags(JspSyntaxSupport.java:600)
     [exec] 	at org.netbeans.modules.web.core.syntax.JSPProcessor.createBeanVarDeclarations(JSPProcessor.java:159)
     [exec] 	at org.netbeans.modules.web.core.syntax.SimplifiedJspServlet.renderProcess(SimplifiedJspServlet.java:262)
     [exec] 	at org.netbeans.modules.web.core.syntax.JSPProcessor$2.run(JSPProcessor.java:348)
     [exec] 	at org.netbeans.editor.BaseDocument.render(BaseDocument.java:1419)
     [exec] 	at org.netbeans.modules.web.core.syntax.JSPProcessor.process(JSPProcessor.java:344)
     [exec] 	at org.netbeans.modules.web.core.syntax.EmbeddingProviderImpl.getEmbeddings(EmbeddingProviderImpl.java:75)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor.callEmbeddingProvider(TaskProcessor.java:599)
     [exec] 	at org.netbeans.modules.parsing.impl.SourceCache.refresh(SourceCache.java:366)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:793)
     [exec] 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:304)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:725)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:686)
     [exec] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
     [exec] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
     [exec] 	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
     [exec] 	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
     [exec] 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
     [exec] 	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
Comment 1 brettryan 2016-07-12 12:56:11 UTC
Marking as regression as this does not appear within 8.1. As it doesn't (appear) to affect functionality am relaxing to P4.
Comment 2 brettryan 2016-07-14 02:36:08 UTC
Created attachment 160381 [details]
Patch replacing dangerous File.toURL() to Utilities.toURI(File).toURL()

File.toURL() [1] should be avoided as it does not escape spaces correctly, one should convert to a URI first and then to a URL.

 [1]: https://docs.oracle.com/javase/8/docs/api/java/io/File.html#toURL--