mirror of
https://github.com/plexusorg/toml4j.git
synced 2025-01-01 13:02:37 +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
|
@ -67,6 +67,10 @@ class Results {
|
||||||
errors.append("Table " + tableName + " defined twice!\n");
|
errors.append("Table " + tableName + " defined twice!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tableName.endsWith(".")) {
|
||||||
|
errors.append("Implicit table name cannot be empty: " + tableName);
|
||||||
|
}
|
||||||
|
|
||||||
while (stack.size() > 1) {
|
while (stack.size() > 1) {
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,26 @@ public class TomlTest {
|
||||||
new Toml().parse("[error] if you didn't catch this, your parser is broken");
|
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) {
|
private File file(String file) {
|
||||||
return new File(getClass().getResource(file + ".toml").getFile());
|
return new File(getClass().getResource(file + ".toml").getFile());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue