aboutsummaryrefslogtreecommitdiff
path: root/src/de.rs
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2018-09-25 16:33:52 +0900
committerrhysd <lin90162@yahoo.co.jp>2018-09-25 16:33:52 +0900
commit2f372b9f1079b866d633d6b5cecfaf573f3480f0 (patch)
tree52b7740ab46eaff37016b53a71f733dc6eba7908 /src/de.rs
parent8181a7e645064426b43891b0f4c7fa86c2a2d154 (diff)
downloadmilf-rs-2f372b9f1079b866d633d6b5cecfaf573f3480f0.tar.gz
milf-rs-2f372b9f1079b866d633d6b5cecfaf573f3480f0.zip
Fix multi-line strings are not allowed for key
In spec https://github.com/toml-lang/toml#keys Quoted keys are clarified as > he exact same rules as either basic strings or literal strings TOML clearly distinguishes basic string and multi-line basic string (literal string is also). https://github.com/toml-lang/toml#string So table key and quoted key should not allow multi-line basic string and multi-line literal string. ABNF definition also describes that. https://github.com/toml-lang/toml/blob/master/toml.abnf ``` string = ml-basic-string / basic-string / ml-literal-string / literal-string quoted-key = basic-string / literal-string ``` `string` contains `ml-*` but `quoted-key` doesn't.
Diffstat (limited to 'src/de.rs')
-rw-r--r--src/de.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/de.rs b/src/de.rs
index 517a62b..491ae47 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -152,6 +152,9 @@ enum ErrorKind {
/// An empty table key was found.
EmptyTableKey,
+ /// Multiline strings are not allowed for key
+ MultilineStringKey,
+
/// A custom error which could be generated when deserializing a particular
/// type.
Custom,
@@ -1274,6 +1277,9 @@ impl<'a> Deserializer<'a> {
TokenError::EmptyTableKey(at) => {
self.error(at, ErrorKind::EmptyTableKey)
}
+ TokenError::MultilineStringKey(at) => {
+ self.error(at, ErrorKind::MultilineStringKey)
+ }
}
}
@@ -1377,6 +1383,7 @@ impl fmt::Display for Error {
}
ErrorKind::RedefineAsArray => "table redefined as array".fmt(f)?,
ErrorKind::EmptyTableKey => "empty table key found".fmt(f)?,
+ ErrorKind::MultilineStringKey => "multiline strings are not allowed for key".fmt(f)?,
ErrorKind::Custom => self.inner.message.fmt(f)?,
ErrorKind::ExpectedString => "expected string".fmt(f)?,
ErrorKind::DottedKeyInvalidType => "dotted key attempted to extend non-table type".fmt(f)?,
@@ -1421,6 +1428,7 @@ impl error::Error for Error {
ErrorKind::DuplicateTable(_) => "duplicate table",
ErrorKind::RedefineAsArray => "table redefined as array",
ErrorKind::EmptyTableKey => "empty table key found",
+ ErrorKind::MultilineStringKey => "invalid multiline string for key",
ErrorKind::Custom => "a custom error",
ErrorKind::ExpectedString => "expected string",
ErrorKind::DottedKeyInvalidType => "dotted key invalid type",