diff --git a/lib/weblib.php b/lib/weblib.php index 76cb3e92ac0..4c97f788820 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1376,8 +1376,9 @@ function format_text($text, $format = FORMAT_MOODLE, $options = null, $courseidd $text = markdown_to_html($text); $filteroptions['stage'] = 'pre_clean'; $text = $filtermanager->filter_text($text, $context, $filteroptions); - // The markdown parser does not strip dangerous html so we need to clean it, even if noclean is set to true. - $text = clean_text($text, FORMAT_HTML, $options); + if (!$options['noclean']) { + $text = clean_text($text, FORMAT_HTML, $options); + } $filteroptions['stage'] = 'post_clean'; $text = $filtermanager->filter_text($text, $context, $filteroptions); break; diff --git a/mod/forum/post.php b/mod/forum/post.php index d8defbfd51f..309a4a77573 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -346,10 +346,7 @@ if (!empty($forum)) { $canreplyprivately = forum_user_can_reply_privately($modcontext, $parent); } - // If markdown is used, the parser does the job already, otherwise clean text from arbitrary code that might be dangerous. - if ($post->messageformat != FORMAT_MARKDOWN) { - $post = trusttext_pre_edit($post, 'message', $modcontext); - } + $post = trusttext_pre_edit($post, 'message', $modcontext); // Unsetting this will allow the correct return URL to be calculated later. unset($SESSION->fromdiscussion);