[ 
https://issues.apache.org/jira/browse/NET-610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15855867#comment-15855867
 ] 

Sergey Yanzin commented on NET-610:
-----------------------------------

Sebb, are you sure NET-611 covers NET-610? I wrote about space preceding line 
containig facts about file (MLST command). NET-611 is about spaces between code 
and text...

Again with a sample:
250- Begin
size=30;type=file;modify=20170205062802; /archive/2017/02/06/mfcrevise/1.txt
250 End

I talked about second line ("size=...") that by RFC should start from space and 
FTPClient skips first character without checking if it is a space really.

RFC requires such a reply:
250- Begin
<space>size=30;type=file;modify=20170205062802; 
/archive/2017/02/06/mfcrevise/1.txt
250 End

> FTPClient.mlistFile incorrectly handles MLST reply
> --------------------------------------------------
>
>                 Key: NET-610
>                 URL: https://issues.apache.org/jira/browse/NET-610
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.5
>         Environment: using some FTP-server incorrectly releasing RFC 3659. 
> For example xlight ftp server (https://www.xlightftpd.com/)
>            Reporter: Sergey Yanzin
>              Labels: easyfix, patch
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> By RFC 3659 server must start fact with space character. But some inaccurate 
> realisations reply without starting space.
> But org.apache.commons.net.ftp.FTPClient.mlistFile() skips leading character 
> even it is not a space:
>     public FTPFile mlistFile(String pathname) throws IOException
>     {
>         boolean success = 
> FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
>         if (success){
>             String entry = getReplyStrings()[1].substring(1); // skip leading 
> space for parser
>             return MLSxEntryParser.parseEntry(entry);
>         } else {
>             return null;
>         }
>     }
> I think it is wrong. The method should throw exception, if first character is 
> not a space. Or does not remove starting char (and should be some option 
> responsible for that behaviour) if it is not a space.
> my workaround in overriden method:
>     public FTPFile mlistFile(String pathname) throws IOException {
>         final boolean success = 
> FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
>         if (success) {
>             final String reply = getReplyStrings()[1];
>             final String entry = reply.charAt(0) == ' ' ? reply.substring(1) 
> : reply;
>             return MLSxEntryParser.parseEntry(entry);
>         } else {
>             return null;
>         }
>     }



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to