mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-73188 tool_usertours: Fix validation of text content
This commit is contained in:
parent
67b2e10f03
commit
e1f34b394d
@ -159,9 +159,19 @@ class editstep extends \moodleform {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate manually entered text content. Validation logic derived from \MoodleQuickForm_Rule_Required::validate()
|
||||
// without the checking of the "strictformsrequired" admin setting.
|
||||
if ($data['contenttype'] == static::CONTENTTYPE_MANUAL) {
|
||||
if (strip_tags($data['content']['text']) == '') {
|
||||
$errors['content'] = get_string('required');
|
||||
$value = $data['content']['text'] ?? '';
|
||||
|
||||
// All tags except img, canvas and hr, plus all forms of whitespaces.
|
||||
$stripvalues = [
|
||||
'#</?(?!img|canvas|hr).*?>#im',
|
||||
'#(\xc2\xa0|\s| )#',
|
||||
];
|
||||
$value = preg_replace($stripvalues, '', (string)$value);
|
||||
if (empty($value)) {
|
||||
$errors['contenthtmlgrp'] = get_string('required');
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +213,7 @@ class editstep extends \moodleform {
|
||||
if ($data->contenttype == static::CONTENTTYPE_LANGSTRING) {
|
||||
$data->content = [
|
||||
'text' => $data->contentlangstring,
|
||||
'format' => 1,
|
||||
'format' => FORMAT_HTML,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user