diff --git a/crates/pptx/src/xml.rs b/crates/pptx/src/xml.rs index 9484863a..b1160a63 100644 --- a/crates/pptx/src/xml.rs +++ b/crates/pptx/src/xml.rs @@ -367,6 +367,7 @@ pub fn esc(s: &str) -> String { '&' => o.push_str("&"), '<' => o.push_str("<"), '>' => o.push_str(">"), + '\r' => o.push_str(" "), c if xml_char(c) => o.push(c), _ => {} } @@ -506,6 +507,15 @@ mod tests { assert_eq!(t, vec!["one\ntwo\nthree\rfour".to_string(), "x\ny".to_string()]); } + #[test] + fn cr_in_text_survives_write_read() { + assert_eq!(esc("a\rb"), "a b"); + let mut w = W::default(); + w.elt("a:t", "one\rtwo\r\nthree"); + let d = parse(w.s.as_bytes()).expect("parse"); + assert_eq!(d.root.text(), "one\rtwo\r\nthree"); + } + #[test] fn parse_basic_and_entities() { let d = parse(b"A & B A <")