Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#257 and #266: Apply censoring before validating new posts and topics…

…. Also censor messages in subscription mails.
  • Loading branch information...
commit 7562628fd5c682893d7e6e69c2baeced61abc163 1 parent 8f855ff
@franzliedke franzliedke authored
Showing with 24 additions and 6 deletions.
  1. +2 −0  lang/English/post.php
  2. +22 −6 post.php
View
2  lang/English/post.php
@@ -5,8 +5,10 @@
// Post validation stuff (many are similiar to those in edit.php)
'No subject' => 'Topics must contain a subject.',
+'No subject after censoring' => 'Topics must contain a subject. After applying censoring filters, your subject was empty.',
'Too long subject' => 'Subjects cannot be longer than 70 characters.',
'No message' => 'You must enter a message.',
+'No message after censoring' => 'You must enter a message. After applying censoring filters, your message was empty.',
'Too long message' => 'Posts cannot be longer that %s bytes.',
'All caps subject' => 'Subjects cannot contain only capital letters.',
'All caps message' => 'Posts cannot contain only capital letters.',
View
28 post.php
@@ -71,9 +71,14 @@
if ($fid)
{
$subject = pun_trim($_POST['req_subject']);
+
+ if ($pun_config['o_censoring'] == '1')
+ $censored_subject = pun_trim(censor_words($subject));
if ($subject == '')
$errors[] = $lang_post['No subject'];
+ else if ($censored_subject == '')
+ $errors[] = $lang_post['No subject after censoring'];
else if (pun_strlen($subject) > 70)
$errors[] = $lang_post['Too long subject'];
else if ($pun_config['p_subject_all_caps'] == '0' && is_all_uppercase($subject) && !$pun_user['is_admmod'])
@@ -135,8 +140,19 @@
$message = preparse_bbcode($message, $errors);
}
- if (empty($errors) && $message == '')
- $errors[] = $lang_post['No message'];
+ if (empty($errors))
+ {
+ if ($message == '')
+ $errors[] = $lang_post['No message'];
+ else if ($pun_config['o_censoring'] == '1')
+ {
+ // Censor message to see if that causes problems
+ $censored_message = pun_trim(censor_words($message));
+
+ if ($censored_message == '')
+ $errors[] = $lang_post['No message after censoring'];
+ }
+ }
$hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
$subscribe = isset($_POST['subscribe']) ? '1' : '0';
@@ -236,7 +252,7 @@
$mail_subject_full = str_replace('<topic_subject>', $cur_posting['subject'], $mail_subject_full);
$mail_message_full = str_replace('<topic_subject>', $cur_posting['subject'], $mail_message_full);
$mail_message_full = str_replace('<replier>', $username, $mail_message_full);
- $mail_message_full = str_replace('<message>', $message, $mail_message_full);
+ $mail_message_full = str_replace('<message>', $pun_config['o_censoring'] == '1' ? $censored_message : $message, $mail_message_full);
$mail_message_full = str_replace('<post_url>', get_base_url().'/viewtopic.php?pid='.$new_pid.'#p'.$new_pid, $mail_message_full);
$mail_message_full = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&tid='.$tid, $mail_message_full);
$mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);
@@ -328,7 +344,7 @@
$mail_message_full = trim(substr($mail_tpl_full, $first_crlf));
$mail_subject = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_subject);
- $mail_message = str_replace('<topic_subject>', $subject, $mail_message);
+ $mail_message = str_replace('<topic_subject>', $pun_config['o_censoring'] == '1' ? $censored_subject : $subject, $mail_message);
$mail_message = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_message);
$mail_message = str_replace('<poster>', $username, $mail_message);
$mail_message = str_replace('<topic_url>', get_base_url().'/viewtopic.php?id='.$new_tid, $mail_message);
@@ -336,10 +352,10 @@
$mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);
$mail_subject_full = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_subject_full);
- $mail_message_full = str_replace('<topic_subject>', $subject, $mail_message_full);
+ $mail_message_full = str_replace('<topic_subject>', $pun_config['o_censoring'] == '1' ? $censored_subject : $subject, $mail_message_full);
$mail_message_full = str_replace('<forum_name>', $cur_posting['forum_name'], $mail_message_full);
$mail_message_full = str_replace('<poster>', $username, $mail_message_full);
- $mail_message_full = str_replace('<message>', $message, $mail_message_full);
+ $mail_message_full = str_replace('<message>', $pun_config['o_censoring'] == '1' ? $censored_message : $message, $mail_message_full);
$mail_message_full = str_replace('<topic_url>', get_base_url().'/viewtopic.php?id='.$new_tid, $mail_message_full);
$mail_message_full = str_replace('<unsubscribe_url>', get_base_url().'/misc.php?action=unsubscribe&fid='.$cur_posting['id'], $mail_message_full);
$mail_message_full = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message_full);
Please sign in to comment.
Something went wrong with that request. Please try again.