aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2018-11-21 09:35:50 -0800
committerEric Huss <eric@huss.org>2018-11-21 09:35:50 -0800
commit2dc1913e0220a4113bd6a9eb165c55cda0bee590 (patch)
tree5a465664c0253556609b6bf285f1807d01e20469
parentf610ef33f4c12e363945ad3c80a1129b0389a699 (diff)
downloadmilf-rs-2dc1913e0220a4113bd6a9eb165c55cda0bee590.tar.gz
milf-rs-2dc1913e0220a4113bd6a9eb165c55cda0bee590.zip
Fix trailing space after date.
The space between date and time was being eagerly skipped when it shouldn't.
-rw-r--r--src/de.rs13
-rw-r--r--test-suite/tests/datetime.rs2
2 files changed, 8 insertions, 7 deletions
diff --git a/src/de.rs b/src/de.rs
index 491ae47..b5633ea 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -1035,13 +1035,12 @@ impl<'a> Deserializer<'a> {
let start = self.tokens.substr_offset(date);
// Check for space separated date and time.
- if let Some((_, Token::Whitespace(s))) = self.peek()? {
- if s == " " {
- self.next()?;
- // Skip past the hour.
- if let Some((_, Token::Keylike(_))) = self.peek()? {
- self.next()?;
- }
+ let mut lookahead = self.tokens.clone();
+ if let Ok(Some((_, Token::Whitespace(" ")))) = lookahead.next() {
+ // Check if hour follows.
+ if let Ok(Some((_, Token::Keylike(_)))) = lookahead.next() {
+ self.next()?; // skip space
+ self.next()?; // skip keylike hour
}
}
diff --git a/test-suite/tests/datetime.rs b/test-suite/tests/datetime.rs
index f3b77e3..a0064fb 100644
--- a/test-suite/tests/datetime.rs
+++ b/test-suite/tests/datetime.rs
@@ -21,6 +21,8 @@ fn times() {
good("1997-09-09T09:09:09-09:09");
good("1997-09-09T09:09:09");
good("1997-09-09");
+ dogood("1997-09-09 ", "1997-09-09");
+ dogood("1997-09-09 # comment", "1997-09-09");
good("09:09:09");
good("1997-09-09T09:09:09.09Z");
good("1997-09-09T09:09:09.09+09:09");