mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-28 19:24:15 +00:00
Empty table names cause parsing to fail
This commit is contained in:
parent
12e73fb314
commit
1b3c08a433
2 changed files with 24 additions and 0 deletions
|
@ -66,6 +66,10 @@ class Results {
|
|||
if (!tables.add(tableName)) {
|
||||
errors.append("Table " + tableName + " defined twice!\n");
|
||||
}
|
||||
|
||||
if (tableName.endsWith(".")) {
|
||||
errors.append("Implicit table name cannot be empty: " + tableName);
|
||||
}
|
||||
|
||||
while (stack.size() > 1) {
|
||||
stack.pop();
|
||||
|
|
|
@ -217,6 +217,26 @@ public class TomlTest {
|
|||
public void should_fail_when_illegal_characters_after_table() throws Exception {
|
||||
new Toml().parse("[error] if you didn't catch this, your parser is broken");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_empty_table_name() {
|
||||
new Toml().parse("[]");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_compound_table_name_ending_with_empty_table_name() {
|
||||
new Toml().parse("[a.]");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_compound_table_name_containing_empty_table_name() {
|
||||
new Toml().parse("[a..b]");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_compound_table_name_starting_with_empty_table_name() {
|
||||
new Toml().parse("[.b]");
|
||||
}
|
||||
|
||||
private File file(String file) {
|
||||
return new File(getClass().getResource(file + ".toml").getFile());
|
||||
|
|
Loading…
Reference in a new issue