[
https://issues.apache.org/jira/browse/VFS-857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17928466#comment-17928466
]
Gary D. Gregory edited comment on VFS-857 at 2/19/25 3:52 PM:
--------------------------------------------------------------
Hello [~imranansari]
Is your IIS configured with "Allow UTF8" set to "true" as in the screenshot
below?
!image-2025-02-19-10-51-08-913.png!
was (Author: garydgregory):
Hello [~imranansari]
Is your IIS configure with "Allow UTF8" set to "true" as in the screenshot
below?
!image-2025-02-19-10-51-08-913.png!
> 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
>
>
> 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)