From 05ffcf05790803d0a49e13c17c98ea771b20823c Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Mon, 7 Aug 2023 09:10:09 +0200 Subject: [PATCH] MDL-78505 Revert "MDL-32114 form: markdown must be preserved on saving post" This partially reverts commit 4a31dd69d6d89818f676ece916e573aa894d49d6. --- lib/weblib.php | 5 +++-- mod/forum/post.php | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) 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);