Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <colinodell@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
 
14
namespace League\CommonMark\Extension\DisallowedRawHtml;
15
 
16
use League\CommonMark\Environment\EnvironmentBuilderInterface;
17
use League\CommonMark\Extension\CommonMark\Node\Block\HtmlBlock;
18
use League\CommonMark\Extension\CommonMark\Node\Inline\HtmlInline;
19
use League\CommonMark\Extension\CommonMark\Renderer\Block\HtmlBlockRenderer;
20
use League\CommonMark\Extension\CommonMark\Renderer\Inline\HtmlInlineRenderer;
21
use League\CommonMark\Extension\ConfigurableExtensionInterface;
22
use League\Config\ConfigurationBuilderInterface;
23
use Nette\Schema\Expect;
24
 
25
final class DisallowedRawHtmlExtension implements ConfigurableExtensionInterface
26
{
27
    private const DEFAULT_DISALLOWED_TAGS = [
28
        'title',
29
        'textarea',
30
        'style',
31
        'xmp',
32
        'iframe',
33
        'noembed',
34
        'noframes',
35
        'script',
36
        'plaintext',
37
    ];
38
 
39
    public function configureSchema(ConfigurationBuilderInterface $builder): void
40
    {
41
        $builder->addSchema('disallowed_raw_html', Expect::structure([
42
            'disallowed_tags' => Expect::listOf('string')->default(self::DEFAULT_DISALLOWED_TAGS)->mergeDefaults(false),
43
        ]));
44
    }
45
 
46
    public function register(EnvironmentBuilderInterface $environment): void
47
    {
48
        $environment->addRenderer(HtmlBlock::class, new DisallowedRawHtmlRenderer(new HtmlBlockRenderer()), 50);
49
        $environment->addRenderer(HtmlInline::class, new DisallowedRawHtmlRenderer(new HtmlInlineRenderer()), 50);
50
    }
51
}