Skip to content

Commit f94d9f6

Browse files
committed
Exercises: add remove_xss
1 parent b8cf026 commit f94d9f6

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

main/exercise/exercise.class.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,8 +3879,18 @@ public function manage_answer(
38793879
$answerDestination = null;
38803880
$userAnsweredQuestion = false;
38813881
$correctAnswerId = [];
3882+
3883+
$userStatus = STUDENT;
3884+
// Allows to do a remove_XSS in question of exercise with user status COURSEMANAGER
3885+
// see BT#18242
3886+
if (api_get_configuration_value('question_exercise_html_strict_filtering')) {
3887+
$userStatus = COURSEMANAGERLOWSECURITY;
3888+
}
3889+
38823890
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
38833891
$answer = $objAnswerTmp->selectAnswer($answerId);
3892+
$answer = Security::remove_XSS($answer, $userStatus);
3893+
38843894
$answerComment = $objAnswerTmp->selectComment($answerId);
38853895
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
38863896
$answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId);

main/exercise/question_list_admin.inc.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,21 @@ function loadEditor(button, questionId) {
337337
[$edit_link, $clone_link, $addImageLink, $delete_link]
338338
);
339339

340-
$title = Security::remove_XSS($objQuestionTmp->selectTitle());
341-
$title = strip_tags($title);
340+
$title = Security::remove_XSS(strip_tags($objQuestionTmp->selectTitle()));
342341
$move = '&nbsp;';
343342
if ($allowQuestionOrdering) {
344343
$move = Display::returnFontAwesomeIcon('arrows moved', 1, true);
345344
}
346345

347346
// Question name
348347
$questionName =
349-
'<a href="#" title = "'.Security::remove_XSS($title).'">
348+
'<a href="#" title = "'.$title.'">
350349
'.$move.' '.cut($title, 42).'
351350
</a>';
352351

353352
// Question type
354353
$typeImg = $objQuestionTmp->getTypePicture();
355354
$typeExpl = $objQuestionTmp->getExplanation();
356-
357355
$questionType = Display::return_icon($typeImg, $typeExpl);
358356

359357
// Question category

main/inc/lib/exercise_show_functions.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public static function display_hotspot_answer(
282282
if (EXERCISE_FEEDBACK_TYPE_EXAM != $feedback_type) {
283283
$content .= '<td class="text-left" width="60%">';
284284
if ($studentChoice) {
285-
$content .= '<span style="font-weight: bold; color: #008000;">'.nl2br($answerComment).'</span>';
285+
$content .= '<span style="font-weight: bold; color: #008000;">'.Security::remove_XSS(nl2br($answerComment)).'</span>';
286286
} else {
287287
$content .= '&nbsp;';
288288
}
@@ -575,7 +575,7 @@ public static function display_multiple_answer_true_false(
575575
if ($hide_expected_answer) {
576576
$color = '';
577577
}
578-
$content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
578+
$content .= '<span style="font-weight: bold; color: '.$color.';">'.Security::remove_XSS(nl2br($answerComment)).'</span>';
579579
}
580580
$content .= '</td>';
581581
}

0 commit comments

Comments
 (0)