diff options
author | Alex Crichton <alex@alexcrichton.com> | 2019-02-19 13:45:23 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-19 13:45:23 -0600 |
commit | 4fb12b493edaae62a3b6fd5320e526ae7cc9542e (patch) | |
tree | 1b45f9ae88c873e581013cc6d199d13d0b70e057 | |
parent | 56f9afb4d2abdf38ed3caf9f819ac8bacc290940 (diff) | |
parent | 8fce90e9cd4be4cbb12b66fedb2de72a73214f15 (diff) | |
download | milf-rs-4fb12b493edaae62a3b6fd5320e526ae7cc9542e.tar.gz milf-rs-4fb12b493edaae62a3b6fd5320e526ae7cc9542e.zip |
Merge pull request #290 from ehuss/fix-case-sensitivity
Fix case sensitivity with T, Z, and E.
-rw-r--r-- | src/datetime.rs | 5 | ||||
-rw-r--r-- | src/de.rs | 5 | ||||
-rw-r--r-- | test-suite/tests/datetime.rs | 2 | ||||
-rw-r--r-- | test-suite/tests/parser.rs | 1 |
4 files changed, 10 insertions, 3 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index 363160b..9239593 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -173,8 +173,9 @@ impl FromStr for Datetime { }; // Next parse the "partial-time" if available + let next = chars.clone().next(); let partial_time = if full_date.is_some() - && (chars.clone().next() == Some('T') || chars.clone().next() == Some(' ')) + && (next == Some('T') || next == Some('t') || next == Some(' ')) { chars.next(); true @@ -253,7 +254,7 @@ impl FromStr for Datetime { // And finally, parse the offset let offset = if offset_allowed { let next = chars.clone().next(); - if next == Some('Z') { + if next == Some('Z') || next == Some('z') { chars.next(); Some(Offset::Z) } else if next.is_none() { @@ -1169,7 +1169,10 @@ impl<'a> Deserializer<'a> { } fn number_or_date(&mut self, span: Span, s: &'a str) -> Result<Value<'a>, Error> { - if s.contains('T') || (s.len() > 1 && s[1..].contains('-')) && !s.contains("e-") { + if s.contains('T') + || s.contains('t') + || (s.len() > 1 && s[1..].contains('-') && !s.contains("e-") && !s.contains("E-")) + { self.datetime(span, s, false) .map(|(Span { start, end }, d)| Value { e: E::Datetime(d), diff --git a/test-suite/tests/datetime.rs b/test-suite/tests/datetime.rs index a0064fb..d6128b0 100644 --- a/test-suite/tests/datetime.rs +++ b/test-suite/tests/datetime.rs @@ -14,6 +14,8 @@ fn times() { fn good(s: &str) { dogood(s, s); dogood(&s.replace("T", " "), s); + dogood(&s.replace("T", "t"), s); + dogood(&s.replace("Z", "z"), s); } good("1997-09-09T09:09:09Z"); diff --git a/test-suite/tests/parser.rs b/test-suite/tests/parser.rs index 2534ce6..69b491d 100644 --- a/test-suite/tests/parser.rs +++ b/test-suite/tests/parser.rs @@ -227,6 +227,7 @@ fn floats() { t!("1.0e0", 1.0); t!("1.0e+0", 1.0); t!("1.0e-0", 1.0); + t!("1E-0", 1.0); t!("1.001e-0", 1.001); t!("2e10", 2e10); t!("2e+10", 2e10); |