fixed bug in commandinterpreter where space(s) behind semicolon, without secondary command (e.g. "nc; ") caused crash

Former-commit-id: 6b7afd141964ecefaae4f8952551859ca6c25c9d
Former-commit-id: dd21356206c45bde1c9f17fc604755d372189d7e
This commit is contained in:
Song Minjae
2016-12-20 14:35:49 +09:00
parent aaa66ccd41
commit efbde62ac5

View File

@@ -37,9 +37,12 @@ object CommandInterpreter {
val error = Error()
for (single_command in cmd) {
if (single_command == null || single_command.argsCount == 0) continue
var commandObj: ConsoleCommand? = null
try {
if (single_command!!.name.toLowerCase().startsWith("qqq")) {
if (single_command.name.toLowerCase().startsWith("qqq")) {
commandObj = CommandDict["qqq"]
}
else if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
@@ -54,28 +57,20 @@ object CommandInterpreter {
throw NullPointerException() // if not authorised, say "Unknown command"
}
}
}
catch (e: NullPointerException) {
}
finally {
Echo("$ccW> $single_command") // prints out the input
println("${ZonedDateTime.now()} [CommandInterpreter] issuing command '$single_command'")
try {
if (commandObj != null) {
commandObj.execute(single_command!!.toStringArray())
}
else {
echoUnknownCmd(single_command!!.name)
// System.out.println("ee3");
}
commandObj.execute(single_command.toStringArray())
}
catch (e: Exception) {
System.err.print("[CommandInterpreter] ")
e.printStackTrace()
EchoError(Lang["ERROR_GENERIC_TEXT"])
}
}
catch (e: NullPointerException) {
echoUnknownCmd(single_command.name)
}
}
}