Skip to content

Quotes are removed from command arguments #20

@Meeples10

Description

@Meeples10

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?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions