From 55a5a64b1a8f0c98bb419f963a7f22db2d09d419 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 9 Jan 2023 05:03:06 +0900 Subject: [PATCH] Fix valid slug spec --- src/routes/blogs.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 295d08a8..a70e403b 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -1,4 +1,7 @@ -use activitystreams::collection::{OrderedCollection, OrderedCollectionPage}; +use activitystreams::{ + collection::{OrderedCollection, OrderedCollectionPage}, + iri_string::{spec::IriSpec, validate::iri_reference}, +}; use diesel::SaveChangesDsl; use rocket::{ http::ContentType, @@ -80,7 +83,7 @@ pub struct NewBlogForm { fn valid_slug(title: &str) -> Result<(), ValidationError> { let slug = Blog::slug(title); - if slug.is_empty() { + if slug.is_empty() || iri_reference::(slug).is_err() { Err(ValidationError::new("empty_slug")) } else { Ok(())