mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-11 02:50:22 -06:00
Merge pull request #2505 from Silvertree2010/fix/h14080-rtf-import-puts-the-text-of-head
Skip RTF header/footer left, right and first-page groups on import
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user