From 2e5ccaf7fe7438badcaf65e4bc84f94de3e8d3be Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 10 Feb 2021 10:27:48 -0500 Subject: [PATCH 1/2] Fixing display name limit. Fixes #1421 --- crates/utils/src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/utils/src/utils.rs b/crates/utils/src/utils.rs index b2a7c97e2..629743568 100644 --- a/crates/utils/src/utils.rs +++ b/crates/utils/src/utils.rs @@ -110,8 +110,8 @@ pub fn is_valid_username(name: &str) -> bool { // Can't do a regex here, reverse lookarounds not supported pub fn is_valid_preferred_username(preferred_username: &str) -> bool { !preferred_username.starts_with('@') - && preferred_username.len() >= 3 - && preferred_username.len() <= 20 + && preferred_username.chars().count() >= 3 + && preferred_username.chars().count() <= 20 } pub fn is_valid_community_name(name: &str) -> bool { From acadf0289e970263fda813ae33c8653297e08a56 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 10 Feb 2021 10:36:22 -0500 Subject: [PATCH 2/2] Fixing reason lengths to char counts. --- crates/api/src/comment.rs | 2 +- crates/api/src/post.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/api/src/comment.rs b/crates/api/src/comment.rs index 5d798d1da..b77e4151a 100644 --- a/crates/api/src/comment.rs +++ b/crates/api/src/comment.rs @@ -672,7 +672,7 @@ impl Perform for CreateCommentReport { if reason.is_empty() { return Err(APIError::err("report_reason_required").into()); } - if reason.len() > 1000 { + if reason.chars().count() > 1000 { return Err(APIError::err("report_too_long").into()); } diff --git a/crates/api/src/post.rs b/crates/api/src/post.rs index 5ab461dc1..7c7afe604 100644 --- a/crates/api/src/post.rs +++ b/crates/api/src/post.rs @@ -749,7 +749,7 @@ impl Perform for CreatePostReport { if reason.is_empty() { return Err(APIError::err("report_reason_required").into()); } - if reason.len() > 1000 { + if reason.chars().count() > 1000 { return Err(APIError::err("report_too_long").into()); }