Ensuring that STAT file listings will not return a file listing record on the last line of multi-line replies (FTPSERVER-414)
git-svn-id: https://svn.apache.org/repos/asf/mina/ftpserver/trunk@1129665 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java b/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
index 6286634..661bdb0 100644
--- a/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
+++ b/core/src/main/java/org/apache/ftpserver/command/impl/STAT.java
@@ -86,11 +86,10 @@
replyCode = FtpReply.REPLY_213_FILE_STATUS;
}
- session
- .write(new LocalizedFileActionFtpReply(
- replyCode,
+ session.write(LocalizedFileActionFtpReply.translate(session, request, context,
+ replyCode, "STAT",
dirList, file));
-
+
} catch (FtpException e) {
session
.write(LocalizedFileActionFtpReply
diff --git a/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties b/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
index 02a9493..5f497f6 100644
--- a/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
+++ b/core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
@@ -232,6 +232,8 @@
213.SIZE={output.msg}
211.STAT=Apache FtpServer\nConnected to {server.ip}\nConnected from {client.ip}\nLogged in as {client.login.name}\nEnd of status.
+212.STAT=\n{output.msg}End of status.
+213.STAT=\n{output.msg}End of status.
450.STAT=Non-existing file
501.STOR=Syntax error in parameters or arguments.
diff --git a/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java b/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java
index 0b02a9e..3398eeb 100644
--- a/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java
+++ b/core/src/test/java/org/apache/ftpserver/clienttests/StatTest.java
@@ -30,7 +30,7 @@
*/
public class StatTest extends ClientTestTemplate {
- private static final String PATTERN = "^21\\d[-\\s]-rw-------\\s\\s\\s1\\suser\\sgroup\\s{12}0\\s[A-Za-z0-9\\s]{6}\\s\\d\\d:\\d\\d\\stest\\d.txt$";
+ private static final String PATTERN = "^-rw-------\\s\\s\\s1\\suser\\sgroup\\s{12}0\\s[A-Za-z0-9\\s]{6}\\s\\d\\d:\\d\\d\\stest\\d.txt$";
private static final File TEST_DIR = new File(ROOT_DIR, "test");
private static final File TEST_FILE1 = new File(TEST_DIR, "test1.txt");
@@ -45,9 +45,8 @@
assertEquals(212, client.stat(TEST_DIR.getName()));
String[] reply = client.getReplyString().split("\r\n");
-
- assertTrue(reply[0], Pattern.matches(PATTERN, reply[0]));
assertTrue(reply[1], Pattern.matches(PATTERN, reply[1]));
+ assertTrue(reply[2], Pattern.matches(PATTERN, reply[2]));
}
public void testStatFile() throws Exception {
@@ -59,7 +58,7 @@
assertEquals(213, client.stat(TEST_DIR.getName() + "/" + TEST_FILE1.getName()));
String[] reply = client.getReplyString().split("\r\n");
- assertTrue(reply[0], Pattern.matches(PATTERN, reply[0]));
+ assertTrue(reply[1], Pattern.matches(PATTERN, reply[1]));
}
public void testStat() throws Exception {