aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs2
-rw-r--r--src/parser.rs10
-rw-r--r--tests/invalid.rs4
-rw-r--r--tests/invalid/key-after-array.toml1
-rw-r--r--tests/invalid/key-after-table.toml1
5 files changed, 17 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ec8106a..21b3e21 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -447,7 +447,7 @@ mod tests {
#[test]
fn lookup_advanced_table() {
- let value: Value = r#"[table."name.other"] value = "my value""#.parse().unwrap();
+ let value: Value = "[table.\"name.other\"]\nvalue = \"my value\"".parse().unwrap();
let looked = value.lookup(r#"table."name.other".value"#).unwrap();
assert_eq!(*looked, Value::String(String::from("my value")));
}
diff --git a/src/parser.rs b/src/parser.rs
index 2a156e3..8c689f8 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -271,6 +271,16 @@ impl<'a> Parser<'a> {
values: BTreeMap::new(),
defined: true,
};
+ self.ws();
+ self.comment();
+ if !self.newline() {
+ self.errors.push(ParserError {
+ lo: start,
+ hi: start,
+ desc: format!("expected a newline after table definition"),
+ });
+ return None
+ }
if !self.values(&mut table) { return None }
if array {
self.insert_array(&mut ret, &keys, Value::Table(table),
diff --git a/tests/invalid.rs b/tests/invalid.rs
index 829e795..63e4de8 100644
--- a/tests/invalid.rs
+++ b/tests/invalid.rs
@@ -50,6 +50,10 @@ test!(float_no_leading_zero,
include_str!("invalid/float-no-leading-zero.toml"));
test!(float_no_trailing_digits,
include_str!("invalid/float-no-trailing-digits.toml"));
+test!(key_after_array,
+ include_str!("invalid/key-after-array.toml"));
+test!(key_after_table,
+ include_str!("invalid/key-after-table.toml"));
test!(key_empty,
include_str!("invalid/key-empty.toml"));
test!(key_hash,
diff --git a/tests/invalid/key-after-array.toml b/tests/invalid/key-after-array.toml
new file mode 100644
index 0000000..5c1a1b0
--- /dev/null
+++ b/tests/invalid/key-after-array.toml
@@ -0,0 +1 @@
+[[agencies]] owner = "S Cjelli"
diff --git a/tests/invalid/key-after-table.toml b/tests/invalid/key-after-table.toml
new file mode 100644
index 0000000..4bc8213
--- /dev/null
+++ b/tests/invalid/key-after-table.toml
@@ -0,0 +1 @@
+[history] guard = "sleeping"