mirror of
https://github.com/plexusorg/toml4j.git
synced 2025-08-04 03:26:01 +00:00
Improved handling of invalid key names
This commit is contained in:
parent
6b67baf3bf
commit
922408e979
2 changed files with 12 additions and 2 deletions
|
@ -146,7 +146,7 @@ public class RegexParser {
|
|||
}
|
||||
|
||||
private boolean isKeyValid(String key) {
|
||||
if (key.contains(".")) {
|
||||
if (key.contains(".") || key.contains("#") || key.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,17 @@ public class TomlTest {
|
|||
public void should_fail_when_dot_in_key_name() throws Exception {
|
||||
new Toml().parse("a.a = 1");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_empty_key_name() throws Exception {
|
||||
new Toml().parse(" = 1");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_key_name_with_hash() throws Exception {
|
||||
new Toml().parse("a# = 1");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void should_fail_on_non_existant_date() throws Exception {
|
||||
new Toml().parse("d = 2012-13-01T15:00:00Z");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue