ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
DocumentPurifier.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\WebDAV\Mount;
22
25use HTMLPurifier_Config;
26
28{
29 private array $allowedTags;
30 protected string $cacheDirectory;
31
32 public function __construct(?array $allowedTags = null, ?string $cacheDirectory = null)
33 {
35 $this->allowedTags = $allowedTags ?? ilRTESettings::_getUsedHTMLTags('textarea');
36
38 }
39
40 protected function getPurifierConfigInstance(): HTMLPurifier_Config
41 {
42 $config = HTMLPurifier_Config::createDefault();
43 $config->set('HTML.DefinitionID', 'ilias termsofservice document');
44 $config->set('HTML.DefinitionRev', 1);
45 $config->set('HTML.TargetBlank', true);
46 $config->set('Cache.SerializerPath', $this->cacheDirectory);
47 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
48
49 $tags = $this->allowedTags;
50 $tags = $this->makeElementListTinyMceCompliant($tags);
51
52 $tags[] = 'b';
53 $tags[] = 'i';
54
55 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
56 $config->set('HTML.ForbiddenAttributes', 'div@style');
57
58 if ($def = $config->maybeGetRawHTMLDefinition()) {
59 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
60 }
61
62 return $config;
63 }
64}
__construct(?array $allowedTags=null, ?string $cacheDirectory=null)
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
static _getUsedHTMLTags(string $module='')
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc