X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapi_crud%2Fsrc%2Fpost%2Fcreate.rs;h=264cdbc829d9cdff851b538562ccc6aedcf826d6;hb=3471f3533cb724b2cf6953d563aadfcc9f66c1d2;hp=458fdb24827d5e1d0711e63a3b7d72a367d2c653;hpb=102124b6d29edd7d799ee12a6f6df05dbbbf4f6c;p=lemmy.git diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 458fdb24..264cdbc8 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -14,6 +14,8 @@ use lemmy_api_common::{ local_site_to_slur_regex, local_user_view_from_jwt, mark_post_as_read, + sanitize_html, + sanitize_html_opt, EndpointType, }, }; @@ -91,6 +93,11 @@ pub async fn create_post( .map(|u| (u.title, u.description, u.embed_video_url)) .unwrap_or_default(); + let name = sanitize_html(data.name.trim()); + let body = sanitize_html_opt(&data.body); + let embed_title = sanitize_html_opt(&embed_title); + let embed_description = sanitize_html_opt(&embed_description); + // Only need to check if language is allowed in case user set it explicitly. When using default // language, it already only returns allowed languages. CommunityLanguage::is_allowed_community_language( @@ -114,9 +121,9 @@ pub async fn create_post( }; let post_form = PostInsertForm::builder() - .name(data.name.trim().to_owned()) + .name(name) .url(url) - .body(data.body.clone()) + .body(body) .community_id(data.community_id) .creator_id(local_user_view.person.id) .nsfw(data.nsfw)