commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35346] New: - NTFTPEntryParser parses directory names starting with a number followed by space incorrectly.
Date Mon, 13 Jun 2005 17:29:53 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35346>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35346

           Summary: NTFTPEntryParser parses directory names starting with a
                    number followed by space incorrectly.
           Product: Commons
           Version: 1.4 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Net
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: gecko@yandex.ru


When I used FTPClient.listFiles() with MS FTP Server I found that directories with names starting
with a 
number followed by space being parsed incorrectly. But when I browse above-mentioned server
with 
Internet Explorer or with Total Commander’s built-in ftp client directory names are shown
correctly.
Now look at the following failing test. (It should be added to NTFTPEntryParserTest class):

    public void testDirectoryBeginningWithNumberFollowedBySpaces() throws Exception
    {
        FTPFile f = getParser().parseFTPEntry("12-03-96  06:38AM       <DIR>       
  123 xyz");
        assertEquals("name", "123 xyz", f.getName());
    }

Junit output:
…
[junit] name expected:<123 ...> but was:<...>
[junit] junit.framework.ComparisonFailure: name expected:<123 ...> but was:<...>
…

The following patch fixes the problem:

Index: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
===============================================================
====
RCS file: /home/cvspublic/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/
NTFTPEntryParser.java,v
retrieving revision 1.19
diff -u -r1.19 NTFTPEntryParser.java
--- jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
	2 Jan 2005 03:17:50 -0000	1.19
+++ jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/NTFTPEntryParser.java
	13 Jun 2005 17:26:16 -0000
@@ -39,8 +39,7 @@
      */
     private static final String REGEX =
         "(\\S+)\\s+(\\S+)\\s+"
-        + "(<DIR>)?\\s*"
-        + "([0-9]+)?\\s+"
+        + "(?:(<DIR>)|([0-9]+))\\s+"
         + "(\\S.*)";
 
     /**

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message