You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rw...@apache.org on 2008/02/19 23:30:08 UTC

svn commit: r629252 - in /commons/proper/net/branches/NET_2_0/src: main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java

Author: rwinston
Date: Tue Feb 19 14:30:06 2008
New Revision: 629252

URL: http://svn.apache.org/viewvc?rev=629252&view=rev
Log:
Add fix for owner name containing spaces (NET-170)

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java?rev=629252&r1=629251&r2=629252&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java Tue Feb 19 14:30:06 2008
@@ -33,12 +33,6 @@
  */
 public class UnixFTPEntryParser extends ConfigurableFTPFileEntryParserImpl
 {
-    /**
-     * months abbreviations looked for by this parser.  Also used
-     * to determine which month is matched by the parser
-     */
-    private static final String DEFAULT_MONTHS =
-        "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)";
     
     static final String DEFAULT_DATE_FORMAT 
 		= "MMM d yyyy"; //Nov 9 2001
@@ -91,8 +85,8 @@
         "([bcdelfmpSs-])"
         +"(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\+?\\s+"
         + "(\\d+)\\s+"
-        + "(\\S+)\\s+"
-        + "(?:(\\S+(?:\\s\\S+)*)\\s+)?"
+        + "(?:(\\S+(?:\\s\\S+)*)\\s+)?"					// owner name (optional spaces)
+        + "(?:(\\S+(?:\\s\\S+)*)\\s+)?" // group name (optional spaces)
         + "(\\d+)\\s+"
         
         /*

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java?rev=629252&r1=629251&r2=629252&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java (original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java Tue Feb 19 14:30:06 2008
@@ -138,6 +138,19 @@
 	protected FTPFileEntryParser getParser() {
 		return (new UnixFTPEntryParser());
 	}
+	
+	public void testOwnerNameWithSpaces() {
+		FTPFile f = getParser().parseFTPEntry("drwxr-xr-x   2 john smith     group         4096 Mar  2 15:13 zxbox");
+		assertNotNull(f);
+		assertEquals("john smith", f.getUser());
+	}
+	
+	public void testOwnerANdGroupNameWithSpaces() {
+		FTPFile f = getParser().parseFTPEntry("drwxr-xr-x   2 john smith     test group         4096 Mar  2 15:13 zxbox");
+		assertNotNull(f);
+		assertEquals("john smith", f.getUser());
+		assertEquals("test group", f.getGroup());
+	}
 
 	/**
 	 * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testParseFieldsOnDirectory()