[ 
https://issues.apache.org/jira/browse/VFS-857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17928660#comment-17928660
 ] 

imran ansari commented on VFS-857:
----------------------------------

Hi [~ggregory] 
I checked out the code repo and built locally. 
Then ran the example client with parameters.
Changed to local user as anonymous user was not able to access.
Ran the example successfully and the output is correct.


{panel:title=Output}
220 Microsoft FTP Service
Connected to localhost on 21
USER *******
331 Password required
PASS *******
230 User logged in.
SYST
215 Windows_NT
Remote system is Windows_NT
OPTS UTF8 ON
200 OPTS UTF8 command successful - UTF8 encoding now ON.
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (127,0,0,1,197,53).
NLST /
125 Data connection already open; Transfer starting.
226 Transfer complete.
/Concreting
/csv
/Guidelines- Legal.pdf
/Guidelines.pdf
/Shuttering
/Steel Calculation
/tips.txt
/Zedem
*/اپنا مکان تعمیر کرنے سے پہلے یہ مضمون ضرور پڑھیں.docx*
NOOP
200 NOOP command successful.
QUIT
221 Goodbye.

Process finished with exit code 0
{panel}

> listFiles() fails if the FTP Server (IIS based) contains any file with name 
> in non-ascii Unicode character
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: VFS-857
>                 URL: https://issues.apache.org/jira/browse/VFS-857
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.9.0, 2.10.0
>         Environment: Microsoft IIS based FTP Server
> !image-2025-02-14-19-24-23-511.png!
>            Reporter: imran ansari
>            Priority: Critical
>         Attachments: Output.png, image-2025-02-14-19-24-23-511.png, 
> image-2025-02-19-10-51-08-913.png, image-2025-02-19-21-01-43-836.png, 
> image-2025-02-19-21-02-31-727.png
>
>
> FTPClient method listFiles() fails if the FTP Server contains a file with 
> name in non-ascii Unicode character. This is mainly reported if the server is 
> {*}Microsoft IIS based{*}.
>  
> VFS2 is not sending "OPTS UTF8 true" in the request for list files.
> The following code does not have any effect in case the FTP Server is IIS.
> {code:java}
> confBuilder.setControlEncoding(options, StandardCharsets.UTF_8.displayName());
> confBuilder.setAutodetectUtf8(options, Boolean.TRUE);
> confBuilder.setFileType(options, FtpFileType.BINARY);{code}
> org.apache.commons.vfs2.FileSystemException: Could not find files in 
> "ftp://192.168.100.8/";
> {code:java}
> package org.example;
> import org.apache.commons.vfs2.FileObject;
> import org.apache.commons.vfs2.FileSystemManager;
> import org.apache.commons.vfs2.FileSystemOptions;
> import org.apache.commons.vfs2.VFS;
> import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder;
> public class Main {
>     public static void main(String[] args) {
>         // FTP server details
>         String host = "192.168.100.8";
>         String username = "imran";
>         String password = "xxxxxxx";
>         String remoteDir = "/";
>         try {
>             System.setProperty("file.encoding", "UTF-8");
>             FileSystemManager fsManager = VFS.getManager();
>             FileSystemOptions opts = new FileSystemOptions();
>             FtpFileSystemConfigBuilder.getInstance().setAutodetectUtf8(opts, 
> true);
>             FtpFileSystemConfigBuilder.getInstance().setControlEncoding(opts, 
> "UTF-8");
>             FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, 
> false);
>             FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, 
> true);
>             String ftpUrl = "ftp://"; + username + ":" + password + "@" + host 
> + remoteDir;
>             FileObject remoteFolder = fsManager.resolveFile(ftpUrl, opts);
>             FileObject[] files = remoteFolder.getChildren();
>             System.out.println("Files in " + remoteDir + ":");
>             for (FileObject file : files) {
>                 String fileName = file.getName().getBaseName();
>                 System.out.println(fileName);
>             }
>             remoteFolder.close();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
>  {code}
>  
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
>     <modelVersion>4.0.0</modelVersion>
>     <parent>
>         <groupId>org.example</groupId>
>         <artifactId>VFS2Test</artifactId>
>         <version>1.0-SNAPSHOT</version>
>     </parent>
>     <artifactId>Test</artifactId>
>     <properties>
>         <maven.compiler.source>17</maven.compiler.source>
>         <maven.compiler.target>17</maven.compiler.target>
>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>     </properties>
>     <dependencies>
>         <dependency>
>             <groupId>commons-net</groupId>
>             <artifactId>commons-net</artifactId>
>             <version>3.12.0-SNAPSHOT</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.commons</groupId>
>             <artifactId>commons-vfs2</artifactId>
>             <version>2.10.1-SNAPSHOT</version>
>         </dependency>
>     </dependencies>
> </project>{code}
>  
> {panel:title=Stack Trace}
> Caused by: org.apache.commons.vfs2.FileSystemException: Could not find files 
> in "ftp://192.168.100.8/";.
>     at 
> org.apache.commons.vfs2//org.apache.commons.vfs2.provider.AbstractFileObject.findFiles(AbstractFileObject.java:1016)
>     at 
> org.apache.commons.vfs2//org.apache.commons.vfs2.provider.AbstractFileObject.listFiles(AbstractFileObject.java:1664)
>     at 
> org.apache.commons.vfs2//org.apache.commons.vfs2.provider.AbstractFileObject.findFiles(AbstractFileObject.java:991)
>     ... 18 more
> Caused by: java.nio.file.InvalidPathException: Illegal char <?> at index 49: 
> /Best Practices & Guidelines/???? ???? ????? ???? ?? ???? ?? ????? ???? 
> ?????.docx
>     at 
> java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
>     at 
> java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
>     at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
>     at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
>     at 
> java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
>     at java.base/java.nio.file.Path.of(Path.java:147)
> {panel}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to