Fix RichParser assuming it should be used if its prefix is short than, and contained by, the input

This commit is contained in:
dordsor21 2021-11-16 12:49:54 +00:00
parent 575b0035df
commit 66357b8adb
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -100,11 +100,14 @@ public abstract class RichParser<E> extends InputParser<E> implements AliasedPar
@Override
public E parseFromInput(String input, ParserContext context) throws InputParseException {
int i = input.indexOf('[');
// Rich parser requires arguments, else, it should not be used
if (i == -1) {
return null;
}
String inputPrefix = input.substring(0, i);
for (String prefix : this.prefixes) {
if (!input.startsWith(prefix)) {
continue;
}
if (input.length() < prefix.length()) {
if (!inputPrefix.equals(prefix)) {
continue;
}
String[] arguments = extractArguments(input.substring(prefix.length()), true);