mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-14 00:14:03 +00:00
Don't allow zero-space char in display name. Fixes #1317
This commit is contained in:
parent
bf7558830f
commit
799ab94af3
2 changed files with 10 additions and 1 deletions
|
@ -32,6 +32,12 @@ fn test_valid_register_username() {
|
||||||
fn test_valid_display_name() {
|
fn test_valid_display_name() {
|
||||||
assert!(is_valid_display_name("hello @there"));
|
assert!(is_valid_display_name("hello @there"));
|
||||||
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]
|
#[test]
|
||||||
|
|
|
@ -109,7 +109,10 @@ pub fn is_valid_username(name: &str) -> bool {
|
||||||
|
|
||||||
// Can't do a regex here, reverse lookarounds not supported
|
// Can't do a regex here, reverse lookarounds not supported
|
||||||
pub fn is_valid_display_name(name: &str) -> bool {
|
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 {
|
pub fn is_valid_community_name(name: &str) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue