diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -248,6 +248,15 @@ fn parse_float(location: &Location, string: &str) -> Result<f64> { }) { return Err(bad_float()); } + for (i, c) in string.bytes().enumerate() { + if c == b'.' { + // decimal point must be preceded and followed by a digit + let ok = |j| string.as_bytes().get(j).is_some_and(u8::is_ascii_digit); + if !(ok(i.wrapping_sub(1)) && ok(i + 1)) { + return Err(bad_float()); + } + } + } string.parse().map_err(|_| bad_float()) } |