diff --git a/src/de.rs b/src/de.rs index 15c8236b6..1824117a0 100644 --- a/src/de.rs +++ b/src/de.rs @@ -898,7 +898,7 @@ impl<'de, R: Read<'de>> Deserializer { fn scan_number(&mut self, buf: &mut String) -> Result<()> { match tri!(self.peek_or_null()) { b'.' => self.scan_decimal(buf), - b'e' | b'E' => self.scan_exponent(buf), + c @ (b'e' | b'E') => self.scan_exponent(c as char, buf), _ => Ok(()), } } @@ -923,19 +923,20 @@ impl<'de, R: Read<'de>> Deserializer { } match tri!(self.peek_or_null()) { - b'e' | b'E' => self.scan_exponent(buf), + c @ (b'e' | b'E') => self.scan_exponent(c as char, buf), _ => Ok(()), } } #[cfg(feature = "arbitrary_precision")] - fn scan_exponent(&mut self, buf: &mut String) -> Result<()> { + fn scan_exponent(&mut self, e: char, buf: &mut String) -> Result<()> { self.eat_char(); - buf.push('e'); + buf.push(e); match tri!(self.peek_or_null()) { b'+' => { self.eat_char(); + buf.push('+'); } b'-' => { self.eat_char(); diff --git a/tests/test.rs b/tests/test.rs index 2fe7c560a..3d701d827 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -1007,8 +1007,14 @@ fn test_parse_number() { #[cfg(feature = "arbitrary_precision")] test_parse_ok(vec![ ("1e999", Number::from_string_unchecked("1e999".to_owned())), + ("1e+999", Number::from_string_unchecked("1e+999".to_owned())), ("-1e999", Number::from_string_unchecked("-1e999".to_owned())), ("1e-999", Number::from_string_unchecked("1e-999".to_owned())), + ("1E999", Number::from_string_unchecked("1E999".to_owned())), + ("1E+999", Number::from_string_unchecked("1E+999".to_owned())), + ("-1E999", Number::from_string_unchecked("-1E999".to_owned())), + ("1E-999", Number::from_string_unchecked("1E-999".to_owned())), + ("1E+000", Number::from_string_unchecked("1E+000".to_owned())), ( "2.3e999", Number::from_string_unchecked("2.3e999".to_owned()),