// Verify that only mods or admins can ban
is_mod_or_admin(context.pool(), local_user_view.person.id, community_id).await?;
- is_valid_body_field(&data.reason)?;
+ is_valid_body_field(&data.reason, false)?;
let community_user_ban_form = CommunityPersonBanForm {
community_id: data.community_id,
// Make sure user is an admin
is_admin(&local_user_view)?;
- is_valid_body_field(&data.reason)?;
+ is_valid_body_field(&data.reason, false)?;
let ban = data.ban;
let banned_person_id = data.person_id;
&data.content.clone(),
&local_site_to_slur_regex(&local_site),
);
- is_valid_body_field(&Some(content_slurs_removed.clone()))?;
+ is_valid_body_field(&Some(content_slurs_removed.clone()), false)?;
// Check for a community ban
let post_id = data.post_id;
.as_ref()
.map(|c| remove_slurs(c, &local_site_to_slur_regex(&local_site)));
- is_valid_body_field(&content_slurs_removed)?;
+ is_valid_body_field(&content_slurs_removed, false)?;
let comment_id = data.comment_id;
let form = CommentUpdateForm::builder()
check_slurs_opt(&data.description, &slur_regex)?;
is_valid_actor_name(&data.name, local_site.actor_name_max_length as usize)?;
- is_valid_body_field(&data.description)?;
+ is_valid_body_field(&data.description, false)?;
// Double check for duplicate community actor_ids
let community_actor_id = generate_local_apub_endpoint(
let slur_regex = local_site_to_slur_regex(&local_site);
check_slurs_opt(&data.title, &slur_regex)?;
check_slurs_opt(&data.description, &slur_regex)?;
- is_valid_body_field(&data.description)?;
+ is_valid_body_field(&data.description, false)?;
// Verify its a mod (only mods can edit it)
let community_id = data.community_id;
let url = data_url.map(clean_url_params).map(Into::into); // TODO no good way to handle a "clear"
is_valid_post_title(&data.name)?;
- is_valid_body_field(&data.body)?;
+ is_valid_body_field(&data.body, true)?;
check_community_ban(local_user_view.person.id, data.community_id, context.pool()).await?;
check_community_deleted_or_removed(data.community_id, context.pool()).await?;
is_valid_post_title(name)?;
}
- is_valid_body_field(&data.body)?;
+ is_valid_body_field(&data.body, true)?;
let post_id = data.post_id;
let orig_post = Post::read(context.pool(), post_id).await?;
&data.content.clone(),
&local_site_to_slur_regex(&local_site),
);
- is_valid_body_field(&Some(content_slurs_removed.clone()))?;
+ is_valid_body_field(&Some(content_slurs_removed.clone()), false)?;
check_person_block(local_user_view.person.id, data.recipient_id, context.pool()).await?;
// Doing the update
let content_slurs_removed = remove_slurs(&data.content, &local_site_to_slur_regex(&local_site));
- is_valid_body_field(&Some(content_slurs_removed.clone()))?;
+ is_valid_body_field(&Some(content_slurs_removed.clone()), false)?;
let private_message_id = data.private_message_id;
PrivateMessage::update(
site_description_length_check(desc)?;
}
- is_valid_body_field(&data.sidebar)?;
+ is_valid_body_field(&data.sidebar, false)?;
let application_question = diesel_option_overwrite(&data.application_question);
check_application_question(
site_description_length_check(desc)?;
}
- is_valid_body_field(&data.sidebar)?;
+ is_valid_body_field(&data.sidebar, false)?;
let application_question = diesel_option_overwrite(&data.application_question);
check_application_question(
.expect("compile regex")
});
const BODY_MAX_LENGTH: usize = 10000;
+const POST_BODY_MAX_LENGTH: usize = 50000;
const BIO_MAX_LENGTH: usize = 300;
fn has_newline(name: &str) -> bool {
}
/// This could be post bodies, comments, or any description field
-pub fn is_valid_body_field(body: &Option<String>) -> LemmyResult<()> {
+pub fn is_valid_body_field(body: &Option<String>, post: bool) -> LemmyResult<()> {
if let Some(body) = body {
- let check = body.chars().count() <= BODY_MAX_LENGTH;
+ let check = if post {
+ body.chars().count() <= POST_BODY_MAX_LENGTH
+ } else {
+ body.chars().count() <= BODY_MAX_LENGTH
+ };
+
if !check {
Err(LemmyError::from_message("invalid_body_field"))
} else {