Skip to content

Commit 6a28e86

Browse files
committed
Revert "Skip only whitespace with a line break."
This reverts commit e2e0cad.
1 parent e2e0cad commit 6a28e86

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/de/mod.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,16 +2789,8 @@ where
27892789
fn skip_whitespaces(&mut self) -> Result<(), DeError> {
27902790
loop {
27912791
match self.peek()? {
2792-
// Skip only blank text nodes that contain a newline or carriage return
2793-
// (typical pretty-printed formatting). Preserve other blank text
2794-
// (e.g. single space) as they may be significant for some deserialization scenarios.
27952792
DeEvent::Text(e) if e.is_blank() => {
2796-
let contains_newline = e.text.chars().any(|c| c == '\n' || c == '\r');
2797-
if contains_newline {
2798-
self.next()?;
2799-
continue;
2800-
}
2801-
break;
2793+
self.next()?;
28022794
}
28032795
_ => break,
28042796
}
@@ -4656,6 +4648,7 @@ mod tests {
46564648
assert_eq!(de.next().unwrap(), DeEvent::Text(" ".into()));
46574649
assert_eq!(de.next().unwrap(), DeEvent::End(BytesEnd::new("tag")));
46584650
assert_eq!(de.next().unwrap(), DeEvent::Eof);
4651+
// Passes as expected
46594652
}
46604653

46614654
// start::text::text has no difference from start::text

tests/serde-de.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ mod text {
4747

4848
let item: Item = from_str(r#"<root>content </root>"#).unwrap();
4949

50+
// Passes as expected
5051
assert_eq!(
5152
item,
5253
Item {
@@ -65,6 +66,7 @@ mod text {
6566

6667
let item: Item = from_str(r#"<root> </root>"#).unwrap();
6768

69+
// Fails: called `Result::unwrap()` on an `Err` value: Custom("missing field `$text`")
6870
assert_eq!(
6971
item,
7072
Item {

0 commit comments

Comments
 (0)