From 28e27ac837e9bc333b1ffe2cc1cd6be10c01bb3e Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 16 Aug 2016 13:44:53 +0800 Subject: [PATCH] MDL-55581 htmlpurifier: allow track tag in videos and audios --- lib/tests/htmlpurifier_test.php | 83 ++++++++++++++++++++++++--------- lib/weblib.php | 14 ++++-- 2 files changed, 71 insertions(+), 26 deletions(-) diff --git a/lib/tests/htmlpurifier_test.php b/lib/tests/htmlpurifier_test.php index 31e3e53c46a..e2924af2968 100644 --- a/lib/tests/htmlpurifier_test.php +++ b/lib/tests/htmlpurifier_test.php @@ -327,7 +327,7 @@ class core_htmlpurifier_testcase extends basic_testcase { * @param string $expected expected result */ public function test_media_tags($mediatag, $expected) { - $actual = format_text($mediatag, FORMAT_MOODLE, ['filter' => false, 'noclean' => true]); + $actual = format_text($mediatag, FORMAT_MOODLE, ['filter' => false]); $this->assertEquals($expected, $actual); } @@ -353,8 +353,8 @@ class core_htmlpurifier_testcase extends basic_testcase { $videoattrs = [ 'crossorigin="anonymous"', 'crossorigin="use-credentials"', 'poster="https://upload.wikimedia.org/wikipedia/en/1/14/Space_jam.jpg"', - 'preload=""', 'autoplay=""', 'playsinline=""', 'loop=""', 'muted=""', - 'controls=""', 'width="420px"', 'height="69px"' + 'preload="auto"', 'autoplay=""', 'playsinline=""', 'loop=""', 'muted=""', + 'controls=""', 'width="420"', 'height="69"' ]; return $generatetestcases('Plain audio', $audioattrs + ['src="http://example.com/jam.wav"'], [ '', @@ -363,7 +363,7 @@ class core_htmlpurifier_testcase extends basic_testcase { '', '
' . '' . '
' @@ -375,21 +375,46 @@ class core_htmlpurifier_testcase extends basic_testcase { 'No tasty jams for you.' . '', '
' . - '
' + ]) + $generatetestcases('Audio with sources and tracks', $audioattrs, [ + '', + '
' . + '' . '
' ]) + $generatetestcases('Plain video', $videoattrs + ['src="http://example.com/prettygood.mp4'], [ '', '
' + ]) + $generatetestcases('Video with illegal subtag', $videoattrs + ['src="http://example.com/prettygood.mp4'], [ + '', + '
' + ]) + $generatetestcases('Video with legal subtag', $videoattrs + ['src="http://example.com/prettygood.mp4'], [ + '', + '
' + ]) + $generatetestcases('Source tag without video or audio', $videoattrs, [ + 'some text the end', + '
some text the end
' ]) + $generatetestcases('Video with one source', $videoattrs, [ '', '
' . '' . '
' @@ -397,38 +422,50 @@ class core_htmlpurifier_testcase extends basic_testcase { '', '
' . '' . '
' - ] + [ - 'Video with invalid crossorigin' => [ - '