Skip to content
Snippets Groups Projects
Commit 0f343644 authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

check format in `purifyFlexibleInput()`, fixes #180

parent 932d46be
No related branches found
No related tags found
No related merge requests found
......@@ -126,10 +126,12 @@ abstract class Exercise extends SimpleORMap
public static function purifyFlexibleInput($html)
{
if (Studip\Markup::isHtml($html)) {
if (preg_match('/<.*</s', $html)) {
$text = Studip\Markup::removeHtml($html);
if (preg_match('/<.*</s', $html) || kill_format($text) !== $text) {
$html = Studip\Markup::purifyHtml($html);
} else {
$html = Studip\Markup::removeHtml($html);
$html = $text;
}
}
......
......@@ -167,15 +167,13 @@ $(function() {
var toggle = $(this).closest('.size_toggle');
var items = toggle.find('.character_input');
for (var i = 0; i < items.length; i += 2) {
var name = items[i].name;
items[i].name = items[i + 1].name;
items[i + 1].name = name;
var name = items[0].name;
items[0].name = items[1].name;
items[1].name = name;
var value = items[i].value;
items[i].value = items[i + 1].value;
items[i + 1].value = value;
}
var value = items[0].value;
items[0].value = items[1].value;
items[1].value = value;
toggle.toggleClass('size_large').toggleClass('size_small');
event.preventDefault();
......
......@@ -426,11 +426,7 @@ function check_exercise_access($exercise_id, $assignment_id)
*/
function vips_flexible_input_size($text)
{
if (strpos($text, "\n") !== false || Studip\Markup::isHtml($text) || kill_format($text) !== $text) {
return 'large';
}
return 'small';
return strpos($text, "\n") === false ? 'small' : 'large';
}
/**
......
......@@ -15,7 +15,7 @@
</tr>
</thead>
<tbody class="dynamic_list">
<tbody class="dynamic_list" style="vertical-align: top;">
<? foreach ($exercise->task['groups'] as $i => $group): ?>
<? $size = vips_flexible_input_size($group) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment