aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2019-04-08 09:09:07 -0500
committerGitHub <noreply@github.com>2019-04-08 09:09:07 -0500
commit1f99a6b9799e3eafe4c534f543547b2f0adaf423 (patch)
treeea03c5625956b1ca1271e20dc18e8bb7e59eaedf
parent166d8f08b3bb70b878664a6689904924c72ab7d6 (diff)
parentc53ed53659f6fbbc1257ee028d4b6e8f06193fdb (diff)
downloadmilf-rs-1f99a6b9799e3eafe4c534f543547b2f0adaf423.tar.gz
milf-rs-1f99a6b9799e3eafe4c534f543547b2f0adaf423.zip
Merge pull request #299 from ehuss/fix-float-suffix
Fix float with invalid suffix.
-rw-r--r--src/de.rs2
-rw-r--r--test-suite/tests/invalid.rs2
-rw-r--r--test-suite/tests/invalid/float-no-suffix.toml1
3 files changed, 5 insertions, 0 deletions
diff --git a/src/de.rs b/src/de.rs
index 6b7c43b..b23f03f 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -1396,6 +1396,8 @@ impl<'a> Deserializer<'a> {
return Err(self.error(start, ErrorKind::NumberInvalid));
}
exponent = Some(a);
+ } else if !suffix.is_empty() {
+ return Err(self.error(start, ErrorKind::NumberInvalid));
}
let mut number = integral
diff --git a/test-suite/tests/invalid.rs b/test-suite/tests/invalid.rs
index 9f36e2c..820c48b 100644
--- a/test-suite/tests/invalid.rs
+++ b/test-suite/tests/invalid.rs
@@ -38,6 +38,8 @@ test!(empty_table,
include_str!("invalid/empty-table.toml"));
test!(float_no_leading_zero,
include_str!("invalid/float-no-leading-zero.toml"));
+test!(float_no_suffix,
+ include_str!("invalid/float-no-suffix.toml"));
test!(float_no_trailing_digits,
include_str!("invalid/float-no-trailing-digits.toml"));
test!(key_after_array,
diff --git a/test-suite/tests/invalid/float-no-suffix.toml b/test-suite/tests/invalid/float-no-suffix.toml
new file mode 100644
index 0000000..76106de
--- /dev/null
+++ b/test-suite/tests/invalid/float-no-suffix.toml
@@ -0,0 +1 @@
+a = 1.2f