DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
End the RTF \uN fallback skip at the end of its group
NetterSilverec510b90695e
diff --git a/crates/textimport/src/rtf.rs b/crates/textimport/src/rtf.rsindex 91a5ae5a3..8d851a2cc 100644--- a/crates/textimport/src/rtf.rs+++ b/crates/textimport/src/rtf.rs@@ -109,6 +109,8 @@ pub fn import(bytes: &[u8]) -> Result<Imported, ImportError> {if stack.len() > 1 {stack.pop();}+ // The `\uN` fallback skip ends with the group.+ pending = 0;fmt = stack.last().map(State::format).unwrap_or_default();i += 1;}@@ -307,4 +309,12 @@ Caf\'e9 \u8364? price\tab tab\line next\par// Half a pair is not a character: it is still left out.assert_eq!(import(br"{\rtf1 A\u-10179?B\u-8704?C}").unwrap().story.text, "ABC");}++ /// A `\uN` at the end of a group has no fallback character inside it. The skip count must+ /// end with the group, not eat the text after it.+ #[test]+ fn unicode_fallback_skip_ends_with_group() {+ assert_eq!(import(br"{\rtf1 {\b \u8364} AB}").unwrap().story.text, "\u{20AC} AB");+ assert_eq!(import(br"{\rtf1 {\uc2\b \u8364} ABC}").unwrap().story.text, "\u{20AC} ABC");+ }}