Skip to content

Commit e527007

Browse files
committed
!!![TASK] Disallow raw directive!
1 parent d51b58c commit e527007

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

packages/typo3-docs-theme/resources/config/typo3-docs-theme.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use phpDocumentor\Guides\RestructuredText\Parser\Productions\DirectiveContentRule;
1616
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1717

18+
use T3Docs\Typo3DocsTheme\Directives\RawDirective;
1819
use T3Docs\Typo3DocsTheme\EventListeners\AddThemeSettingsToProjectNode;
1920
use T3Docs\Typo3DocsTheme\EventListeners\CopyResources;
2021
use T3Docs\Typo3DocsTheme\Directives\GroupTabDirective;
@@ -59,6 +60,7 @@
5960
->public()
6061

6162
->set(GroupTabDirective::class)
63+
->set(RawDirective::class)
6264
->set(T3FieldListTableDirective::class)
6365
->set(YoutubeDirective::class)
6466
->set(CodeHighlight::class)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link https://phpdoc.org
12+
*/
13+
14+
namespace T3Docs\Typo3DocsTheme\Directives;
15+
16+
use phpDocumentor\Guides\RestructuredText\Directives\ActionDirective;
17+
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
18+
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
19+
use Psr\Log\LoggerInterface;
20+
21+
final class RawDirective extends ActionDirective
22+
{
23+
public function __construct(
24+
private readonly LoggerInterface $logger
25+
) {}
26+
27+
public function getName(): string
28+
{
29+
return 'raw';
30+
}
31+
32+
public function processAction(BlockContext $blockContext, Directive $directive): void
33+
{
34+
$this->logger->error('The raw directive is not supported for security reasons. ', $blockContext->getLoggerInformation());
35+
}
36+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- content start -->
2+
<section class="section" id="raw-directive-must-not-work">
3+
<h1>Raw directive must not work<a class="headerlink" href="#raw-directive-must-not-work" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4+
5+
</section>
6+
7+
<!-- content end -->
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app.ERROR: The raw directive is not supported for security reasons.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app.ERROR: The raw directive is not supported for security reasons.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
===========================
2+
Raw directive must not work
3+
===========================
4+
5+
.. raw:: html
6+
7+
<div style="background-color: red; color: black;">This HTML must not show!!</div>
8+
9+
<script>alert('Some very bad JavaScript works!!!')</script>

0 commit comments

Comments
 (0)