Browse Source

Allow audio tag works with htmlpurifier

Fix #2265
Angel Fernando Quiroz Campos 7 years ago
parent
commit
faf0d7e528

+ 9 - 0
main/inc/lib/formvalidator/Rule/allowed_tags.inc.php

@@ -316,6 +316,15 @@ $allowed_tags_student['video']['src'] = array();
 $allowed_tags_student['video']['controls'] = array();
 $allowed_tags_student['video']['id'] = array();
 
+$allowed_tags_student['audio'] = array();
+$allowed_tags_student['audio']['autoplay'] = array();
+$allowed_tags_student['audio']['src'] = array();
+$allowed_tags_student['audio']['loop'] = array();
+$allowed_tags_student['audio']['preload'] = array();
+$allowed_tags_student['audio']['controls'] = array();
+$allowed_tags_student['audio']['muted'] = array();
+$allowed_tags_student['audio']['id'] = array();
+
 $allowed_tags_student['source'] = array();
 $allowed_tags_student['source']['type'] = array();
 $allowed_tags_student['source']['src'] = array();

+ 16 - 1
main/inc/lib/security.lib.php

@@ -364,7 +364,7 @@ class Security
             $config->set('HTML.DefinitionID', 'html5-definitions'); // unqiue id
             $config->set('HTML.DefinitionRev', 1);
             if ($def = $config->maybeGetRawHTMLDefinition()) {
-                // http://developers.whatwg.org/the-video-element.html#the-video-element
+                // https://html.spec.whatwg.org/dev/media.html#the-video-element
                 $def->addElement(
                     'video',
                     'Block',
@@ -380,6 +380,21 @@ class Security
                         'controls' => 'Bool',
                     )
                 );
+                // https://html.spec.whatwg.org/dev/media.html#the-audio-element
+                $def->addElement(
+                    'audio',
+                    'Block',
+                    'Optional: (source, Flow) | (Flow, source) | Flow',
+                    'Common',
+                    array(
+                        'autoplay' => 'Bool',
+                        'src'      => 'URI',
+                        'loop'     => 'Bool',
+                        'preload'  => 'Enum#auto,metadata,none',
+                        'controls' => 'Bool',
+                        'muted'    => 'Bool',
+                    )
+                );
                 $def->addElement(
                     'source',
                     'Block',