Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-610

FTPClient.mlistFile incorrectly handles MLST reply

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5
    • 3.6
    • FTP
    • using some FTP-server incorrectly releasing RFC 3659. For example xlight ftp server (https://www.xlightftpd.com/)

    • Patch, Important

    Description

      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; }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            xuthus Sergey Yanzin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified