You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/12/12 12:15:55 UTC

svn commit: r1420619 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/ftp/FTPClient.java

Author: sebb
Date: Wed Dec 12 11:15:54 2012
New Revision: 1420619

URL: http://svn.apache.org/viewvc?rev=1420619&view=rev
Log:
NET-492 FTPClient.printWorkingDirectory() incorrectly parses certain valid PWD command results

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1420619&r1=1420618&r2=1420619&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml (original)
+++ commons/proper/net/trunk/src/changes/changes.xml Wed Dec 12 11:15:54 2012
@@ -62,7 +62,13 @@ The <action> type attribute can be add,u
      -->
 
     <body>
-        <release version="3.2" date="TBA" description="
+        <release version="3.3" date="TBA" description="
+        ">
+            <action issue="NET-492" dev="sebb" type="fix">
+            FTPClient.printWorkingDirectory() incorrectly parses certain valid PWD command results
+            </action>
+        </release>
+        <release version="3.2" date="2012-12-03" description="
 This release fixes bugs and adds some new functionality (see below).
  It is binary compatible with previous releases.
  Note that Clirr shows that two public methods have been removed (NET-485). These are not used within NET.

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java?rev=1420619&r1=1420618&r2=1420619&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java Wed Dec 12 11:15:54 2012
@@ -484,11 +484,12 @@ implements Configurable
 
     /**
      * Parse the pathname from a CWD reply.
+     * <p>
      * According to RFC959 (http://www.ietf.org/rfc/rfc959.txt), 
-     * it should be the same as for MKD, i.e.
-     * 257<space>"<directory-name>"<space><commentary>
-     * where any embedded double-quotes are doubled.
-     * 
+     * it should be the same as for MKD - but without commentary - i.e.
+     * {@code 257<space>"<directory-name>"}
+     * where any double-quotes in <directory-name> are doubled.
+     * <p>
      * However, see NET-442 for an exception.
      * 
      * @param reply
@@ -496,16 +497,12 @@ implements Configurable
      */
     private static String __parsePathname(String reply)
     {
-        int begin = reply.indexOf('"'); // find first double quote
-        if (begin == -1) { // not found, return all after reply code and space
-            return reply.substring(REPLY_CODE_LEN + 1);
-        }
-        int end = reply.lastIndexOf("\" "); // N.B. assume commentary does not contain double-quote
-        if (end != -1 ){ // found end of quoted string, de-duplicate any embedded quotes
-            return reply.substring(begin+1, end).replace("\"\"", "\"");            
+        String param = reply.substring(REPLY_CODE_LEN + 1);
+        if (param.startsWith("\"") && param.endsWith("\"")) {
+            return param.substring(1, param.length()-1).replace("\"\"", "\"");            
         }
         // malformed reply, return all after reply code and space
-        return reply.substring(REPLY_CODE_LEN + 1);
+        return param;
     }
 
     /**