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 0e7e1c2e9..3584cdedc 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 0067ad09a..63c53c401 100644 --- a/pkgs/id/src/invite.rs +++ b/pkgs/id/src/invite.rs @@ -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}",