MDL-78505 Revert "MDL-32114 form: markdown must be preserved on saving post"

This partially reverts commit 4a31dd69d6d89818f676ece916e573aa894d49d6.
This commit is contained in:
Petr Skoda 2023-08-07 09:10:09 +02:00
parent 478abd671f
commit a50c2d4746
2 changed files with 4 additions and 6 deletions

View File

@ -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;

View File

@ -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);