Changed quote escaping to space escaping
This commit is contained in:
@@ -295,41 +295,28 @@ public class Executable extends org.bukkit.command.Command {
|
|||||||
if (args_.length == 0) {
|
if (args_.length == 0) {
|
||||||
args = new String[0];
|
args = new String[0];
|
||||||
}else{
|
}else{
|
||||||
char[] rawArgs = (String.join(" ", args_) + ' ').toCharArray();
|
ArrayList<String> tempArgs = new ArrayList<String>();
|
||||||
int argSize = 0;
|
String temp = "";
|
||||||
char last = '\0';
|
int counter = 0;
|
||||||
boolean inString = false;
|
for (String s : args_) {
|
||||||
|
if (s.endsWith("\\")) {
|
||||||
for (char c : rawArgs) {
|
if ((s.length() > 1 && s.charAt(s.length() - 2) == '\\') || counter + 1 == args_.length) {
|
||||||
if (c == '"') {
|
// escaped \
|
||||||
if (last != '\\') {
|
tempArgs.add(temp + s.replace("\\\\", "\\"));
|
||||||
inString = !inString;
|
temp = "";
|
||||||
}
|
|
||||||
}else if (c == ' ' && !inString) {
|
|
||||||
argSize++;
|
|
||||||
}
|
|
||||||
last = c;
|
|
||||||
}
|
|
||||||
last = '\0';
|
|
||||||
args = new String[argSize];
|
|
||||||
String buffer = "";
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
for (char c : rawArgs) {
|
|
||||||
if (c == '"') {
|
|
||||||
if (last != '\\') {
|
|
||||||
inString = !inString;
|
|
||||||
}else{
|
}else{
|
||||||
buffer = buffer.substring(0, buffer.length() - 1) + '"';
|
// unescaped \
|
||||||
|
temp += s.substring(0, s.length() - 1).replace("\\\\", "\\") + " ";
|
||||||
}
|
}
|
||||||
}else if (c == ' ' && !inString) {
|
|
||||||
args[index] = buffer;
|
|
||||||
buffer = "";
|
|
||||||
index++;
|
|
||||||
}else{
|
}else{
|
||||||
buffer += c;
|
tempArgs.add(temp + s);
|
||||||
|
temp = "";
|
||||||
}
|
}
|
||||||
last = c;
|
counter++;
|
||||||
|
}
|
||||||
|
args = new String[tempArgs.size()];
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
args[i] = tempArgs.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<ExecutableDefinition> defs = new ArrayList<ExecutableDefinition>();
|
ArrayList<ExecutableDefinition> defs = new ArrayList<ExecutableDefinition>();
|
||||||
|
|||||||
Reference in New Issue
Block a user