diff --git a/lib/weblib.php b/lib/weblib.php index f88921bfb3b..1ad946b7903 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1365,8 +1365,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 9ea0f2aef31..ccf57f14acb 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -343,10 +343,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);