Bug 63222

Summary: file named tilde (~) makes another file ending with ~ appears twice
Product: Ant Reporter: Eugène Adell <eugene.adell>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: minor    
Priority: P2    
Version: 1.10.5   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Eugène Adell 2019-03-03 00:35:10 UTC
When one file is strictly named ~ (tilde) and one or more file names end with ~, one of these files appears twice.

How to reproduce (I could reproduce 100%) : I have one directory published over FTP, which contains these files :
$ ls -AFlb
total 0
-rw-r--r--. 1 caolila users 0 Mar  3 01:00 ~
-rw-r--r--. 1 caolila users 0 Mar  3 01:08 1~
-rw-r--r--. 1 caolila users 0 Mar  3 01:08 2~
-rw-r--r--. 1 caolila users 0 Mar  3 01:08 3~


Listing this directory with an ANT FTPClient gives the following :

$ more toc.txt
-r--------   1 user group            0 Mar  3 01:08 1~
-r--------   1 user group            0 Mar  3 01:08 2~
-r--------   1 user group            0 Mar  3 01:08 3~
-r--------   1 user group            0 Mar  3 01:08 1~


Native FTPClient lists correctly :
Connected to localhost.
220 Service ready for new user.
-r--------   1 user group            0 Mar  3 01:08 1~
-r--------   1 user group            0 Mar  3 01:08 2~
-r--------   1 user group            0 Mar  3 01:08 3~
-r--------   1 user group            0 Mar  3 01:00 ~


If using characters instead of numbers in the file names, I get the same issue

FTPClient
220 Service ready for new user.
-r--------   1 user group            0 Mar  3 00:55 charactersthen~
-r--------   1 user group            0 Mar  3 01:00 ~

ANT
$ more toc.txt
-r--------   1 user group            0 Mar  3 00:55 charactersthen~
-r--------   1 user group            0 Mar  3 00:55 charactersthen~


It seems that the first file of the list appears twice, which is not a random behavior.

Note that the problem happens only when the ~ is at the end. If it is at another place, or at the beginning, no problem as we see :

FTPClient
220 Service ready for new user.
-r--------   1 user group            0 Mar  3 01:00 ~
-r--------   1 user group            0 Mar  3 00:55 ~thencharacters

ANT
$ more toc.txt
-r--------   1 user group            0 Mar  3 01:00 ~
-r--------   1 user group            0 Mar  3 00:55 ~thencharacters


My ANT target is :
  <target name="listing">
    <ftp action="list"
       listing="toc.txt"
       server="localhost"
       port="2121"
       userid="anonymous"
       password="anonymous"
       remotedir=".">
   <fileset dir="." defaultexcludes="no" includes="*" />
    </ftp>
  </target>