Fix quoted strings being parsed as booleans
This commit is contained in:
parent
559d8f3972
commit
2fb712212a
2 changed files with 13 additions and 1 deletions
|
@ -233,7 +233,7 @@ public class StringReader implements ImmutableStringReader {
|
||||||
|
|
||||||
public boolean readBoolean() throws CommandSyntaxException {
|
public boolean readBoolean() throws CommandSyntaxException {
|
||||||
final int start = cursor;
|
final int start = cursor;
|
||||||
final String value = readString();
|
final String value = readUnquotedString();
|
||||||
if (value.isEmpty()) {
|
if (value.isEmpty()) {
|
||||||
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerExpectedBool().createWithContext(this);
|
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerExpectedBool().createWithContext(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,4 +585,16 @@ public class StringReaderTest {
|
||||||
assertThat(ex.getCursor(), is(0));
|
assertThat(ex.getCursor(), is(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readBoolean_quoted() throws Exception {
|
||||||
|
final StringReader reader = new StringReader("\"true\"");
|
||||||
|
try {
|
||||||
|
reader.readBoolean();
|
||||||
|
fail();
|
||||||
|
} catch (final CommandSyntaxException ex) {
|
||||||
|
assertThat(ex.getType(), is(CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerExpectedBool()));
|
||||||
|
assertThat(ex.getCursor(), is(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue