From 06528bfb2b23fb5aa3900680fad3dc756b811ea1 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 12:06:25 -0600 Subject: [PATCH] fix(id): use shared Cf helper in invite validation --- pkgs/id/src/commands/group.rs | 6 +++--- pkgs/id/src/commands/text.rs | 18 ++++++++++++++++++ pkgs/id/src/invite.rs | 7 ++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pkgs/id/src/commands/group.rs b/pkgs/id/src/commands/group.rs index d11fe95d4..114d21cbd 100644 --- a/pkgs/id/src/commands/group.rs +++ b/pkgs/id/src/commands/group.rs @@ -671,11 +671,11 @@ mod tests { #[test] fn test_every_named_format_char_is_escaped_alone_and_with_a_space() { - // The full Cf set named in #3111's acceptance: U+202A-202E, U+2066-2069, - // U+200E/U+200F, U+200B, U+FEFF, U+00AD. + // The named Cf cases in #3111's acceptance: U+202A-202E, U+2066-2069, + // U+200B-U+200F, U+FEFF, U+00AD. let named: Vec = (0x202a..=0x202e) .chain(0x2066..=0x2069) - .chain([0x200e, 0x200f, 0x200b, 0xfeff, 0x00ad]) + .chain([0x200b, 0x200c, 0x200d, 0x200e, 0x200f, 0xfeff, 0x00ad]) .map(|cp| char::from_u32(cp).expect("named Cf code point")) .collect(); for c in named { diff --git a/pkgs/id/src/commands/text.rs b/pkgs/id/src/commands/text.rs index 0b56d370d..6a76d621f 100644 --- a/pkgs/id/src/commands/text.rs +++ b/pkgs/id/src/commands/text.rs @@ -228,6 +228,24 @@ mod tests { serde_json::from_str::(&with_tab).unwrap(), "a\u{202e}\tb" ); + + // Join controls are part of the same Cf set: escape them in both the + // Cf-only and already-quoted paths without losing the stored value. + let joiner_alone = plain_field("\u{200d}"); + assert_eq!(joiner_alone, r#""\u200d""#); + assert!(!joiner_alone.contains('\u{200d}')); + assert_eq!( + serde_json::from_str::(&joiner_alone).unwrap(), + "\u{200d}" + ); + + let joiner_with_tab = plain_field("a\u{200d}\tb"); + assert_eq!(joiner_with_tab, r#""a\u200d\tb""#); + assert!(!joiner_with_tab.contains('\u{200d}')); + assert_eq!( + serde_json::from_str::(&joiner_with_tab).unwrap(), + "a\u{200d}\tb" + ); } #[test] diff --git a/pkgs/id/src/invite.rs b/pkgs/id/src/invite.rs index 0b7012b48..63c53c401 100644 --- a/pkgs/id/src/invite.rs +++ b/pkgs/id/src/invite.rs @@ -40,7 +40,7 @@ impl Invite { "an invite name cannot contain control characters" ); ensure!( - !name.chars().any(crate::petname::is_format_char), + !name.chars().any(crate::is_format_char), "an invite name cannot contain format characters" ); let name = name.trim(); @@ -342,11 +342,12 @@ mod tests { #[test] fn format_characters_are_refused() { - // Representative Cf: soft hyphen, zero-width space, a bidi - // override, the BOM/zero-width no-break space, a tag char. + // Representative Cf: soft hyphen, zero-width space and joiner, a + // bidi override, the BOM/zero-width no-break space, a tag char. for name in [ "Ann\u{ad}Lee", "Ann\u{200b}Lee", + "Ann\u{200d}Lee", "Ann\u{202e}Lee", "\u{feff}Ann", "Ann\u{e0041}",