From ec510b90695e66b9fc1edf25c38cf115726d7b24 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Thu, 15 Oct 2026 04:39:17 +0000 Subject: [PATCH] End the RTF \uN fallback skip at the end of its group Found while testing crates/textimport/src/rtf.rs:107 Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Opus 5.5 --- crates/textimport/src/rtf.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/textimport/src/rtf.rs b/crates/textimport/src/rtf.rs index 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 { 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"); + } }