fix issue 10405: if the parameter contains Spaces, the invoke telnet command will fail. (#10669)
* fix issue 10405: if the parameter contains Spaces, the invoke telnet command will fail. * code optimizing.
This commit is contained in:
parent
2c54859b0b
commit
14fb253f03
|
|
@ -25,11 +25,15 @@ public class TelnetCommandDecoder {
|
|||
public static final CommandContext decode(String str) {
|
||||
CommandContext commandContext = null;
|
||||
if (!StringUtils.isBlank(str)) {
|
||||
str = str.trim();
|
||||
String[] array = str.split("(?<![\\\\]) ");
|
||||
if (array.length > 0) {
|
||||
String name = array[0];
|
||||
String[] targetArgs = new String[array.length - 1];
|
||||
System.arraycopy(array, 1, targetArgs, 0, array.length - 1);
|
||||
String name = array[0].trim();
|
||||
if (name.equals("invoke") && array.length > 2) {
|
||||
targetArgs = reBuildInvokeCmdArgs(str);
|
||||
}
|
||||
commandContext = CommandContextFactory.newInstance( name, targetArgs,false);
|
||||
commandContext.setOriginRequest(str);
|
||||
}
|
||||
|
|
@ -38,4 +42,8 @@ public class TelnetCommandDecoder {
|
|||
return commandContext;
|
||||
}
|
||||
|
||||
private static String[] reBuildInvokeCmdArgs(String cmd) {
|
||||
return new String[] {cmd.substring(cmd.indexOf(" ") + 1).trim()};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue