feat: filter invisible chars in title

This commit is contained in:
2022-08-30 23:36:44 +08:00
parent 86b736dadb
commit dd110be8c7

View File

@@ -208,7 +208,12 @@ pub struct TitleInput {
#[post("/title", data = "<ti>")] #[post("/title", data = "<ti>")]
pub async fn set_title(ti: Form<TitleInput>, user: CurrentUser, rconn: RdsConn) -> JsonApi { pub async fn set_title(ti: Form<TitleInput>, user: CurrentUser, rconn: RdsConn) -> JsonApi {
if CustomTitle::set(&rconn, &user.namehash, &ti.title).await? { let title: String = ti.title.chars().filter(|c| c.is_alphanumeric()).collect();
if title.is_empty() {
Err(TitleUsed)?
}
if CustomTitle::set(&rconn, &user.namehash, &title).await? {
code0!() code0!()
} else { } else {
Err(TitleUsed)? Err(TitleUsed)?