Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

RTF: a group opening ends the \uN fallback skip

Brandon Thomas13d17e7a6d57
diff --git a/crates/textimport/src/rtf.rs b/crates/textimport/src/rtf.rs
index 410455669..3060d7ea3 100644
--- a/crates/textimport/src/rtf.rs
+++ b/crates/textimport/src/rtf.rs
@@ -95,6 +95,8 @@ pub fn import(bytes: &[u8]) -> Result<Imported, ImportError> {
stack.push(top);
}
first = false;
+ // A group is not a character: the `\uN` fallback skip ends here too.
+ pending = 0;
// `{\*\dest …}`: an ignorable destination.
if chars.get(i + 1) == Some(&'\\')
&& chars.get(i + 2) == Some(&'*')
@@ -337,6 +339,8 @@ Caf\'e9 \u8364? price\tab tab\line next\par
assert_eq!(i.story.text, "\u{201C}Hi\u{201D} x\u{2014}y");
let i = import(br"{\rtf1 \u8220\{Hi}").unwrap();
assert_eq!(i.story.text, "\u{201C}Hi");
+ let i = import(br"{\rtf1 \u8220{\b Hi}}").unwrap();
+ assert_eq!(i.story.text, "\u{201C}Hi");
}
/// Characters past U+FFFF are written as two `\uN` words, a UTF-16 surrogate pair (the form