fn test_valid_display_name() {
assert!(is_valid_display_name("hello @there"));
assert!(!is_valid_display_name("@hello there"));
+
+ // Make sure zero-space with an @ doesn't work
+ assert!(!is_valid_display_name(&format!(
+ "{}@my name is",
+ '\u{200b}'
+ )));
}
#[test]
// Can't do a regex here, reverse lookarounds not supported
pub fn is_valid_display_name(name: &str) -> bool {
- !name.starts_with('@') && name.chars().count() >= 3 && name.chars().count() <= 20
+ !name.starts_with('@')
+ && !name.starts_with('\u{200b}')
+ && name.chars().count() >= 3
+ && name.chars().count() <= 20
}
pub fn is_valid_community_name(name: &str) -> bool {