ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
class.ilHtmlForumPostPurifier.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected function getPurifierConfigInstance(): HTMLPurifier_Config
28 {
29 $config = HTMLPurifier_Config::createDefault();
30 $config->set('HTML.DefinitionID', 'ilias forum post');
31 $config->set('HTML.DefinitionRev', 3);
32 $config->set('Cache.SerializerPath', ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory());
33 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
34
35 $tags = ilRTESettings::_getUsedHTMLTags('frm_post');
36 $tags = $this->makeElementListTinyMceCompliant($tags);
37 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
38 $config->set('HTML.ForbiddenAttributes', 'div@style');
39
40 $config->autoFinalize = false;
41 $config->set(
42 'URI.AllowedSchemes',
43 array_merge(
44 $config->get('URI.AllowedSchemes'),
45 ['data' => true]
46 )
47 );
48 $config->autoFinalize = true;
49
50 if (($def = $config->maybeGetRawHTMLDefinition()) !== null) {
51 $def->addAttribute('img', 'data-id', 'Number');
52 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
53 }
54
55 return $config;
56 }
57}
Concrete class for sanitizing html of forum posts.
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
static _getUsedHTMLTags(string $module='')