commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1420638 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java
Date Wed, 12 Dec 2012 12:25:06 GMT
Author: sebb
Date: Wed Dec 12 12:25:05 2012
New Revision: 1420638

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

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

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=1420638&r1=1420637&r2=1420638&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 12:25:05 2012
@@ -498,8 +498,16 @@ implements Configurable
     private static String __parsePathname(String reply)
     {
         String param = reply.substring(REPLY_CODE_LEN + 1);
-        if (param.startsWith("\"") && param.endsWith("\"")) {
-            return param.substring(1, param.length()-1).replace("\"\"", "\"");          
 
+        if (param.startsWith("\"")) {
+            int end;
+            if (param.endsWith("\"")) {
+                end = param.length()-1;
+            } else { // perhaps there's a trailing comment
+                end=param.lastIndexOf("\" "); // find start of comment (assume it does not
contain ")
+            }
+            if (end != -1) { // It was a match
+                return param.substring(1, end).replace("\"\"", "\"");            
+            }
         }
         // malformed reply, return all after reply code and space
         return param;



Mime
View raw message