diff --git a/lib/medialib.php b/lib/medialib.php index 78507a9482f..d59fe5777ce 100644 --- a/lib/medialib.php +++ b/lib/medialib.php @@ -811,7 +811,7 @@ class core_media_player_wmp extends core_media_player { - + @@ -875,7 +875,7 @@ class core_media_player_qt extends core_media_player { - + @@ -934,14 +934,14 @@ class core_media_player_rm extends core_media_player { data="$url" width="$width" height="$height""> - + @@ -990,7 +990,7 @@ class core_media_player_swf extends core_media_player { - + diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 7ba916b4fb7..145952f36fc 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -7600,6 +7600,18 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { 'tag' => core_text::strtolower($tagmatchings[1]), 'pos' => core_text::strlen($truncate), ); + } else if (preg_match('/^$/s', $linematchings[1], $tagmatchings)) { + $tagdetails[] = (object) array( + 'open' => false, + 'tag' => core_text::strtolower('if'), + 'pos' => core_text::strlen($truncate), + ); } } // Add html-tag to $truncate'd text. @@ -7685,7 +7697,11 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { // Close all unclosed html-tags. foreach ($opentags as $tag) { - $truncate .= '' . $tag . '>'; + if ($tag === 'if') { + $truncate .= ''; + } else { + $truncate .= '' . $tag . '>'; + } } return $truncate; diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 78b2a2d16bd..c976de32987 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -869,6 +869,14 @@ class core_moodlelib_testcase extends advanced_testcase { "tags that ...
", shorten_text($text)); } + public function test_shorten_text_with_tags_and_html_comment() { + $text = "Long text with ". + "tags that will ". + "be chopped off but should be added back again
Long text with " . + "tags that ...