mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-78259 weblib: purify audio/video tags as inline elements
This commit is contained in:
parent
063ffc8073
commit
ea1253efa7
2 changed files with 9 additions and 3 deletions
|
@ -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>',
|
'<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">' .
|
'<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>'
|
'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, [
|
]) + $generatetestcases('Source tag without video or audio', $videoattrs, [
|
||||||
'some text <source src="http://example.com/getup.wav" type="audio/wav"> the end',
|
'some text <source src="http://example.com/getup.wav" type="audio/wav"> the end',
|
||||||
'<div class="text_to_html">some text the end</div>'
|
'<div class="text_to_html">some text the end</div>'
|
||||||
|
|
|
@ -1872,7 +1872,7 @@ function purify_html($text, $options = array()) {
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
|
|
||||||
$config->set('HTML.DefinitionID', 'moodlehtml');
|
$config->set('HTML.DefinitionID', 'moodlehtml');
|
||||||
$config->set('HTML.DefinitionRev', 6);
|
$config->set('HTML.DefinitionRev', 7);
|
||||||
$config->set('Cache.SerializerPath', $cachedir);
|
$config->set('Cache.SerializerPath', $cachedir);
|
||||||
$config->set('Cache.SerializerPermissions', $CFG->directorypermissions);
|
$config->set('Cache.SerializerPermissions', $CFG->directorypermissions);
|
||||||
$config->set('Core.NormalizeNewlines', false);
|
$config->set('Core.NormalizeNewlines', false);
|
||||||
|
@ -1914,7 +1914,7 @@ function purify_html($text, $options = array()) {
|
||||||
|
|
||||||
// Media elements.
|
// Media elements.
|
||||||
// https://html.spec.whatwg.org/#the-video-element
|
// 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',
|
'src' => 'URI',
|
||||||
'crossorigin' => 'Enum#anonymous,use-credentials',
|
'crossorigin' => 'Enum#anonymous,use-credentials',
|
||||||
'poster' => 'URI',
|
'poster' => 'URI',
|
||||||
|
@ -1928,7 +1928,7 @@ function purify_html($text, $options = array()) {
|
||||||
'height' => 'Length',
|
'height' => 'Length',
|
||||||
]);
|
]);
|
||||||
// https://html.spec.whatwg.org/#the-audio-element
|
// 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',
|
'src' => 'URI',
|
||||||
'crossorigin' => 'Enum#anonymous,use-credentials',
|
'crossorigin' => 'Enum#anonymous,use-credentials',
|
||||||
'preload' => 'Enum#auto,metadata,none',
|
'preload' => 'Enum#auto,metadata,none',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue