You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Max (JIRA)" <ji...@apache.org> on 2011/01/07 21:35:46 UTC

[jira] Created: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
------------------------------------------------------------------------------------------------------------

                 Key: NET-349
                 URL: https://issues.apache.org/jira/browse/NET-349
             Project: Commons Net
          Issue Type: Bug
          Components: FTP
    Affects Versions: 2.2
         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
RedHat Enterprise Linux
            Reporter: Max
            Priority: Minor


Create 3 files
File with new lines:
echo > 'test
line1
line2
line3.txt'

2 files without:
echo > test1
echo > testz

connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
The file with new lines will return as test and trailing components of the path will be missing.

FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max commented on NET-349:
-------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
-       "([bcdelfmpSs-])"
+       "(?s)([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-        return reader.readLine();
+        String entry = reader.readLine();
+        String line = null;
+        do
+        {
+            reader.mark(256);
+            line = reader.readLine();
+            if(line == null || line.equals("") || matches(line))
+            {
+                reader.reset();
+                line = null;
+                break;
+            }
+            else
+            {
+                entry += "\n"+line;
+            }
+        } while(StringUtils.isNotBlank(line));
+        return entry;
    }


> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max edited comment on NET-349 at 1/11/11 2:53 PM:
--------------------------------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
+String line = null;+
+do+
+{+
+reader.mark(256);+
+line = reader.readLine();+
+if(line == null || line.equals("") || matches(line))+
+{+
+reader.reset();+
+line = null;+
+break;+
+}+
+else+
+{+
+entry += "\n"+line;+
+}+
+} while(StringUtils.isNotBlank(line));+
+return entry;+
    }

In this case listing comes through just fine. Deletion however is not possible, since servers do not support deletion of file names with special characters.

      was (Author: maxf):
    One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
+String line = null;+
+do+
+{+
+reader.mark(256);+
+line = reader.readLine();+
+if(line == null || line.equals("") || matches(line))+
+{+
+reader.reset();+
+line = null;+
+break;+
+}+
+else+
+{+
+entry += "\n"+line;+
+}+
+} while(StringUtils.isNotBlank(line));+
+return entry;+
    }

  
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] [Resolved] (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved NET-349.
----------------------

    Resolution: Won't Fix

Impossible to fix this in general.

For example, the following listing appears to show 3 files:

{noformat}
drwxrwxr-x    2 user     user            4 Oct  5 18:39 .
drwx--x--x   35 user     user          174 Oct  5 18:28 ..
-rw-rw-r--    1 user     user            1 Oct  5 18:35 test1.txt
-rw-rw-r--    1 user     user            1 Oct  5 18:38 test2.txt
-rw-rw-r--    1 user     user            1 Oct  5 18:35 test3.txt
{noformat}

However, in fact there are only 2, as there is an NL in the name after 'test2.txt'.
                
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max edited comment on NET-349 at 1/11/11 2:45 PM:
--------------------------------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
-"([bcdelfmpSs-])"-
+"(?s)([bcdelfmpSs-])"+


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
--        return reader.readLine();
+        String entry = reader.readLine();
+        String line = null;
+        do
+        {
+            reader.mark(256);
+            line = reader.readLine();
+            if(line == null || line.equals("") || matches(line))
+            {
+                reader.reset();
+                line = null;
+                break;
+            }
+            else
+            {
+                entry += "\n"+line;
+            }
+        } while(StringUtils.isNotBlank(line));
+        return entry;
    }


      was (Author: maxf):
    One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
--       "([bcdelfmpSs-])"
+       "(?s)([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
--        return reader.readLine();
+        String entry = reader.readLine();
+        String line = null;
+        do
+        {
+            reader.mark(256);
+            line = reader.readLine();
+            if(line == null || line.equals("") || matches(line))
+            {
+                reader.reset();
+                line = null;
+                break;
+            }
+            else
+            {
+                entry += "\n"+line;
+            }
+        } while(StringUtils.isNotBlank(line));
+        return entry;
    }

  
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max edited comment on NET-349 at 1/11/11 2:48 PM:
--------------------------------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
+        String line = null;+
+       do+
+       {+
+            reader.mark(256);+
+            line = reader.readLine();+
+            if(line == null || line.equals("") || matches(line))+
+            {+
+                reader.reset();+
+                line = null;+
+                break;+
+            }+
+            else+
+            {+
+                entry += "\n"+line;+
+            }+
+        } while(StringUtils.isNotBlank(line));+
+        return entry;+
    }


      was (Author: maxf):
    One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
-"([bcdelfmpSs-])"-
+"(?s)([bcdelfmpSs-])"+


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
--        return reader.readLine();
+        String entry = reader.readLine();
+        String line = null;
+        do
+        {
+            reader.mark(256);
+            line = reader.readLine();
+            if(line == null || line.equals("") || matches(line))
+            {
+                reader.reset();
+                line = null;
+                break;
+            }
+            else
+            {
+                entry += "\n"+line;
+            }
+        } while(StringUtils.isNotBlank(line));
+        return entry;
    }

  
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max edited comment on NET-349 at 1/11/11 2:44 PM:
--------------------------------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
--       "([bcdelfmpSs-])"
+       "(?s)([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
--        return reader.readLine();
+        String entry = reader.readLine();
+        String line = null;
+        do
+        {
+            reader.mark(256);
+            line = reader.readLine();
+            if(line == null || line.equals("") || matches(line))
+            {
+                reader.reset();
+                line = null;
+                break;
+            }
+            else
+            {
+                entry += "\n"+line;
+            }
+        } while(StringUtils.isNotBlank(line));
+        return entry;
    }


      was (Author: maxf):
    One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
-       "([bcdelfmpSs-])"
+       "(?s)([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-        return reader.readLine();
+        String entry = reader.readLine();
+        String line = null;
+        do
+        {
+            reader.mark(256);
+            line = reader.readLine();
+            if(line == null || line.equals("") || matches(line))
+            {
+                reader.reset();
+                line = null;
+                break;
+            }
+            else
+            {
+                entry += "\n"+line;
+            }
+        } while(StringUtils.isNotBlank(line));
+        return entry;
    }

  
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max edited comment on NET-349 at 1/11/11 2:51 PM:
--------------------------------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
 +String line = null;+
+do+
+ {+
+reader.mark(256);+
+line = reader.readLine();+
+if(line == null || line.equals("") || matches(line))+
+{+
+reader.reset();+
+line = null;+
+break;+
+}+
+else+
+{+
+entry += "\n"+line;+
+}+
+} while(StringUtils.isNotBlank(line));+
+return entry;+
    }


      was (Author: maxf):
    One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
+        String line = null;+
+       do+
+       {+
+            reader.mark(256);+
+            line = reader.readLine();+
+            if(line == null || line.equals("") || matches(line))+
+            {+
+                reader.reset();+
+                line = null;+
+                break;+
+            }+
+            else+
+            {+
+                entry += "\n"+line;+
+            }+
+        } while(StringUtils.isNotBlank(line));+
+        return entry;+
    }

  
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character

Posted by "Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980291#action_12980291 ] 

Max edited comment on NET-349 at 1/11/11 2:51 PM:
--------------------------------------------------

One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
+String line = null;+
+do+
+{+
+reader.mark(256);+
+line = reader.readLine();+
+if(line == null || line.equals("") || matches(line))+
+{+
+reader.reset();+
+line = null;+
+break;+
+}+
+else+
+{+
+entry += "\n"+line;+
+}+
+} while(StringUtils.isNotBlank(line));+
+return entry;+
    }


      was (Author: maxf):
    One solution:

Modify UnixFTPEntryParser.java:

     private static final String REGEX =
"+(?s)+([bcdelfmpSs-])"


Modify FTPFileEntryParserImpl.java:

     public String readNextEntry(BufferedReader reader) throws IOException
     {
-return reader.readLine();-
+String entry = reader.readLine();+
 +String line = null;+
+do+
+ {+
+reader.mark(256);+
+line = reader.readLine();+
+if(line == null || line.equals("") || matches(line))+
+{+
+reader.reset();+
+line = null;+
+break;+
+}+
+else+
+{+
+entry += "\n"+line;+
+}+
+} while(StringUtils.isNotBlank(line));+
+return entry;+
    }

  
> FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NET-349
>                 URL: https://issues.apache.org/jira/browse/NET-349
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 2.2
>         Environment: Linux localhost 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux
> RedHat Enterprise Linux
>            Reporter: Max
>            Priority: Minor
>
> Create 3 files
> File with new lines:
> echo > 'test
> line1
> line2
> line3.txt'
> 2 files without:
> echo > test1
> echo > testz
> connect via ftpclient to the server containing these files, switch to that  directory and call listFiles().
> The file with new lines will return as test and trailing components of the path will be missing.
> FTPFileEntryParserImpl.readNextEntry() is using BufferedReader.readLine() to identify the end of the entry. May be some other approach is needed to identify the end of the entry, since file names with new lines although undesired, are actually valid in unix environments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.