[ 
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.

Reply via email to