This is an automated email from the ASF dual-hosted git repository. elecharny pushed a commit to branch 1.1.X in repository https://gitbox.apache.org/repos/asf/mina-ftpserver.git
The following commit(s) were added to refs/heads/1.1.X by this push: new ae7974f5 o Applied Arturo's PR o Code formatting ae7974f5 is described below commit ae7974f5cf0b3f2131923196e29eef56c856820a Author: emmanuel lecharny <elecha...@apache.org> AuthorDate: Mon Apr 4 23:51:21 2022 +0200 o Applied Arturo's PR o Code formatting --- .../apache/ftpserver/command/impl/OPTS_MLST.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/org/apache/ftpserver/command/impl/OPTS_MLST.java b/core/src/main/java/org/apache/ftpserver/command/impl/OPTS_MLST.java index 196d619a..8e5012a7 100644 --- a/core/src/main/java/org/apache/ftpserver/command/impl/OPTS_MLST.java +++ b/core/src/main/java/org/apache/ftpserver/command/impl/OPTS_MLST.java @@ -61,6 +61,7 @@ public class OPTS_MLST extends AbstractCommand { String listTypes; String types[]; int spIndex = argument.indexOf(' '); + if (spIndex == -1) { types = new String[0]; listTypes = ""; @@ -70,36 +71,39 @@ public class OPTS_MLST extends AbstractCommand { // parse all the type tokens StringTokenizer st = new StringTokenizer(listTypes, ";"); types = new String[st.countTokens()]; + for (int i = 0; i < types.length; ++i) { types[i] = st.nextToken(); } } + // set the list types String[] validatedTypes = validateSelectedTypes(types); - if (validatedTypes != null) { + + //if (validatedTypes.length != 0) { session.setAttribute("MLST.types", validatedTypes); session.write(LocalizedFtpReply.translate(session, request, context, FtpReply.REPLY_200_COMMAND_OKAY, "OPTS.MLST", listTypes)); - } else { + /*} else { session.write(LocalizedFtpReply.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "OPTS.MLST", listTypes)); - } + }*/ } - private String[] validateSelectedTypes(final String types[]) { - + private String[] validateSelectedTypes(String... types) { // ignore null types if (types == null) { return new String[0]; } List<String> selectedTypes = new ArrayList<String>(); + // check all the types - for (int i = 0; i < types.length; ++i) { - for (int j = 0; j < AVAILABLE_TYPES.length; ++j) { - if (AVAILABLE_TYPES[j].equalsIgnoreCase(types[i])) { - selectedTypes.add(AVAILABLE_TYPES[j]); + for (String type:types) { + for (String availableType: AVAILABLE_TYPES) { + if (availableType.equalsIgnoreCase( type )) { + selectedTypes.add(availableType); break; } }