Merge branch 'MDL-78259-htmlpurify-media-tags' of https://github.com/DSI-Universite-Rennes2/moodle

This commit is contained in:
Ilya Tregubov 2023-06-20 14:35:21 +08:00
commit 346548e21a
No known key found for this signature in database
GPG Key ID: 0F58186F748E55C1
2 changed files with 9 additions and 3 deletions

View File

@ -426,6 +426,12 @@ class htmlpurifier_test extends \basic_testcase {
'<video %1$s>Did not work <a href="http://example.com/prettygood.mp4">click here to download</a></video>',
'<div class="text_to_html"><video %1$s>Did not work <a href="http://example.com/prettygood.mp4">' .
'click here to download</a></video></div>'
]) + $generatetestcases('Video inside an inline tag', $videoattrs + ['src="http://example.com/prettygood.mp4'], [
'<em><video %1$s>Oh, that\'s pretty bad 😦</video></em>',
'<div class="text_to_html"><em><video %1$s>Oh, that\'s pretty bad 😦</video></em></div>'
]) + $generatetestcases('Video inside a block tag', $videoattrs + ['src="http://example.com/prettygood.mp4'], [
'<p><video %1$s>Oh, that\'s pretty bad 😦</video></p>',
'<div class="text_to_html"><p><video %1$s>Oh, that\'s pretty bad 😦</video></p></div>'
]) + $generatetestcases('Source tag without video or audio', $videoattrs, [
'some text <source src="http://example.com/getup.wav" type="audio/wav"> the end',
'<div class="text_to_html">some text the end</div>'

View File

@ -1888,7 +1888,7 @@ function purify_html($text, $options = array()) {
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'moodlehtml');
$config->set('HTML.DefinitionRev', 6);
$config->set('HTML.DefinitionRev', 7);
$config->set('Cache.SerializerPath', $cachedir);
$config->set('Cache.SerializerPermissions', $CFG->directorypermissions);
$config->set('Core.NormalizeNewlines', false);
@ -1930,7 +1930,7 @@ function purify_html($text, $options = array()) {
// Media elements.
// https://html.spec.whatwg.org/#the-video-element
$def->addElement('video', 'Block', 'Optional: #PCDATA | Flow | source | track', 'Common', [
$def->addElement('video', 'Inline', 'Optional: #PCDATA | Flow | source | track', 'Common', [
'src' => 'URI',
'crossorigin' => 'Enum#anonymous,use-credentials',
'poster' => 'URI',
@ -1944,7 +1944,7 @@ function purify_html($text, $options = array()) {
'height' => 'Length',
]);
// https://html.spec.whatwg.org/#the-audio-element
$def->addElement('audio', 'Block', 'Optional: #PCDATA | Flow | source | track', 'Common', [
$def->addElement('audio', 'Inline', 'Optional: #PCDATA | Flow | source | track', 'Common', [
'src' => 'URI',
'crossorigin' => 'Enum#anonymous,use-credentials',
'preload' => 'Enum#auto,metadata,none',