Reject "+" and "-" when parsing floats.

Fixes #29042
This commit is contained in:
Robin Kruppe
2015-10-14 19:27:49 +02:00
parent e3cd872418
commit 71dcd7f70c
2 changed files with 18 additions and 1 deletions

View File

@@ -59,7 +59,12 @@ pub fn parse_decimal(s: &str) -> ParseResult {
let s = s.as_bytes();
let (integral, s) = eat_digits(s);
match s.first() {
None => Valid(Decimal::new(integral, b"", 0)),
None => {
if integral.is_empty() {
return Invalid; // No digits at all
}
Valid(Decimal::new(integral, b"", 0))
}
Some(&b'e') | Some(&b'E') => {
if integral.is_empty() {
return Invalid; // No digits before 'e'