These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the league/commonmark package. |
||
5 | * |
||
6 | * (c) Colin O'Dell <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace League\CommonMark\Extension\DisallowedRawHtml; |
||
13 | |||
14 | use League\CommonMark\ElementRendererInterface; |
||
15 | use League\CommonMark\Inline\Element\AbstractInline; |
||
16 | use League\CommonMark\Inline\Renderer\InlineRendererInterface; |
||
17 | use League\CommonMark\Util\ConfigurationAwareInterface; |
||
18 | use League\CommonMark\Util\ConfigurationInterface; |
||
19 | |||
20 | final class DisallowedRawHtmlInlineRenderer implements InlineRendererInterface, ConfigurationAwareInterface |
||
21 | { |
||
22 | private $htmlInlineRenderer; |
||
23 | |||
24 | 78 | public function __construct(InlineRendererInterface $htmlBlockRenderer) |
|
25 | { |
||
26 | 78 | $this->htmlInlineRenderer = $htmlBlockRenderer; |
|
27 | 78 | } |
|
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 9 | public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer) |
|
33 | { |
||
34 | 9 | $rendered = $this->htmlInlineRenderer->render($inline, $htmlRenderer); |
|
35 | |||
36 | 9 | if ($rendered === '') { |
|
37 | return ''; |
||
38 | } |
||
39 | |||
40 | // Match these types of tags: <title> </title> <title x="sdf"> <title/> <title /> |
||
41 | 9 | return preg_replace('/<(\/?(?:title|textarea|style|xmp|iframe|noembed|noframes|script|plaintext)[ \/>])/i', '<$1', $rendered); |
|
0 ignored issues
–
show
Bug
Compatibility
introduced
by
Loading history...
|
|||
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 78 | public function setConfiguration(ConfigurationInterface $configuration) |
|
48 | { |
||
49 | 78 | if ($this->htmlInlineRenderer instanceof ConfigurationAwareInterface) { |
|
50 | 78 | $this->htmlInlineRenderer->setConfiguration($configuration); |
|
51 | } |
||
52 | 78 | } |
|
53 | } |
||
54 |