From 55729a5128c5f1519b0c60ded8d5f6e44205e2c5 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Mon, 9 Nov 2026 02:45:42 +0100 Subject: [PATCH] Skip RTF header/footer left, right and first-page groups on import Found while testing crates/textimport/src/rtf.rs:43-63 (SKIP list) and :201 (`SKIP.contains(&word.as_str())`) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/textimport/src/rtf.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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");