Rejectd illegal characters from blog name

This commit is contained in:
Kitaiti Makoto 2023-01-05 02:46:07 +09:00
parent 2d10ddb9fa
commit 9776374d17
1 changed files with 2 additions and 0 deletions

View File

@ -82,6 +82,8 @@ fn valid_slug(title: &str) -> Result<(), ValidationError> {
let slug = Blog::slug(title); let slug = Blog::slug(title);
if slug.is_empty() { if slug.is_empty() {
Err(ValidationError::new("empty_slug")) Err(ValidationError::new("empty_slug"))
} else if slug.contains(&['<', '>', '&', '@', '\'', '"', ' ', '\n', '\t'][..]) {
Err(ValidationError::new("slug_illegal_char"))
} else { } else {
Ok(()) Ok(())
} }