Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 2143 invoked from network); 11 Jan 2011 19:53:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Jan 2011 19:53:09 -0000 Received: (qmail 15491 invoked by uid 500); 11 Jan 2011 19:53:09 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 15407 invoked by uid 500); 11 Jan 2011 19:53:09 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 15199 invoked by uid 99); 11 Jan 2011 19:53:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jan 2011 19:53:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jan 2011 19:53:07 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id p0BJqjjj012128 for ; Tue, 11 Jan 2011 19:52:45 GMT Message-ID: <7891403.293211294775565481.JavaMail.jira@thor> Date: Tue, 11 Jan 2011 14:52:45 -0500 (EST) From: "Max (JIRA)" To: issues@commons.apache.org Subject: [jira] Issue Comment Edited: (NET-349) FTPClient.listFiles() returns a file entry containing a new line character only up to the new line character In-Reply-To: <12806697.219851294432546572.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on 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.