[ https://issues.apache.org/jira/browse/VFS-840?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17883442#comment-17883442 ]
Gary D. Gregory commented on VFS-840: ------------------------------------- Hello [~mbellew] Please try 2.10.0-SNAPSHOT from git master or the snapshot repository: [https://repository.apache.org/content/repositories/snapshots] TY > IllegalArgumentException when using special characters in filename eg [ or ] > and calling FileObject.getPath method > ------------------------------------------------------------------------------------------------------------------ > > Key: VFS-840 > URL: https://issues.apache.org/jira/browse/VFS-840 > Project: Commons VFS > Issue Type: Bug > Affects Versions: 2.9.0 > Environment: Windows 10 > Java 17 > Apache VFS 2.9.0 > Reporter: Usman Ashraf Bajwah > Priority: Major > > When special characters ([ or ] for example there might be others also) are > used in filename FileObject resolve it alright but calling its getPath method > fails with following exception. > > +java.lang.IllegalArgumentException+{color:#ff0000}: Illegal character in > path at index 17: file:///D:/citrus[1].jpg{color} > {color:#ff0000} at > java.base/java.net.URI.create({color}+URI.java:906+{color:#ff0000}){color} > {color:#ff0000} at > org.apache.commons.vfs2.FileObject.getURI({color}+FileObject.java:310+{color:#ff0000}){color} > {color:#ff0000} at > org.apache.commons.vfs2.FileObject.getPath({color}+FileObject.java:320+{color:#ff0000}){color} > {color:#ff0000} at > com.gallerysystems.tms.common.util.FileUtil.main({color}+FileUtil.java:859+{color:#ff0000}){color} > {color:#ff0000}Caused by: > {color}+java.net.URISyntaxException+{color:#ff0000}: Illegal character in > path at index 17: file:///D:/citrus[1].jpg{color} > {color:#ff0000} at > java.base/java.net.URI$Parser.fail({color}+URI.java:2974+{color:#ff0000}){color} > {color:#ff0000} at > java.base/java.net.URI$Parser.checkChars({color}+URI.java:3145+{color:#ff0000}){color} > {color:#ff0000} at > java.base/java.net.URI$Parser.parseHierarchical({color}+URI.java:3227+{color:#ff0000}){color} > {color:#ff0000} at > java.base/java.net.URI$Parser.parse({color}+URI.java:3175+{color:#ff0000}){color} > {color:#ff0000} at > java.base/java.net.URI.<init>({color}+URI.java:623+{color:#ff0000}){color} > {color:#ff0000} at > java.base/java.net.URI.create({color}+URI.java:904+{color:#ff0000}){color} > {color:#ff0000} ... 3 more{color} > > Following is the code to reproduce the issue. > {color:#7f0055}try{color}{color:#000000} {{color} > {color:#000000} String {color}{color:#6a3e3e}fileName{color}{color:#000000} = > {color}{color:#2a00ff}"D:\\citrus[1].jpg"{color}{color:#000000};{color} > {color:#000000} FileSystemManager > {color}{color:#6a3e3e}fsManager{color}{color:#000000} = > VFS.{color}{color:#000000}getManager{color}{color:#000000}();{color} > {color:#000000} FileObject > {color}{color:#6a3e3e}fileObject{color}{color:#000000} = > {color}{color:#6a3e3e}fsManager{color}{color:#000000}.resolveFile({color}{color:#6a3e3e}fileName{color}{color:#000000});{color} > {color:#000000} > System.{color}{color:#0000c0}out{color}{color:#000000}.println({color}{color:#6a3e3e}fileObject{color}{color:#000000}.getPath());{color} > {color:#000000} }{color}{color:#7f0055}catch{color}{color:#000000}(Exception > {color}{color:#6a3e3e}ex{color}{color:#000000}) {{color} > {color:#000000} > {color}{color:#6a3e3e}ex{color}{color:#000000}.printStackTrace();{color} > {color:#000000} }{color} -- This message was sent by Atlassian Jira (v8.20.10#820010)