diff --git a/crates/textimport/src/rtf.rs b/crates/textimport/src/rtf.rs index f750aa385..6660356aa 100644 --- a/crates/textimport/src/rtf.rs +++ b/crates/textimport/src/rtf.rs @@ -47,7 +47,13 @@ const SKIP: &[&str] = &[ "info", "pict", "header", + "headerl", + "headerr", + "headerf", "footer", + "footerl", + "footerr", + "footerf", "footnote", "listtable", "listoverridetable", @@ -310,6 +316,15 @@ fn cp1252(b: u8) -> char { mod tests { use super::*; + #[test] + fn header_and_footer_variants_are_skipped() { + for w in ["header", "headerl", "headerr", "headerf", "footer", "footerl", "footerr", "footerf"] { + let rtf = format!(r"{{\rtf1\ansi {{\{w} Page head\par}}Body text\par}}"); + let text = import(rtf.as_bytes()).unwrap().story.text; + assert_eq!(text.trim_end(), "Body text", "{w}"); + } + } + #[test] fn out_of_range_unicode_escape_is_dropped() { assert_eq!(import(br"{\rtf1 a\u4294967361?b}").unwrap().story.text, "ab");