Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quotes are removed from command arguments #20

Open
Meeples10 opened this issue Jan 25, 2020 · 1 comment
Open

Quotes are removed from command arguments #20

Meeples10 opened this issue Jan 25, 2020 · 1 comment

Comments

@Meeples10
Copy link

If there is an even number of quotes in the arguments of a command, the outer pair is always removed. The string a "string with "quotes"" becomes a string with "quotes", for example. This is not always desirable (see PGMDev/PGM#259).

This appears to be the cause of the problem:

case '"':
final StringBuilder build = new StringBuilder();
final char quotedChar = arg.charAt(0);
int endIndex;
for (endIndex = i; endIndex < args.length; ++endIndex) {
final String arg2 = args[endIndex];
if (arg2.charAt(arg2.length() - 1) == quotedChar && arg2.length() > 1) {
if (endIndex != i) {
build.append(' ');
}
build.append(arg2.substring(endIndex == i ? 1 : 0, arg2.length() - 1));
break;
}
else if (endIndex == i) {
build.append(arg2.substring(1));
}
else {
build.append(' ').append(arg2);
}
}
if (endIndex < args.length) {
arg = build.toString();
i = endIndex;
}
// In case there is an empty quoted string
if (arg.isEmpty()) {
continue;
}
// else raise exception about hanging quotes?
}

@Pablete1234
Copy link

When you have "some argument" it's fine if it gets parsed as a single arg if it's between ", the issue comes with @Text arguments where it should consume all remaining input, and shouldn't be trying to parse strings inside there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants