Skip to content

Commit 2d0965e

Browse files
committed
Fix the escaping of the source code when displaying it
The source code of the controller cannot be considered as being safe HTML. It needs to be escaped. This also moves the escaping of the template source code from the extension to the template rendering it.
1 parent d3f456d commit 2d0965e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/Resources/views/default/_source_code.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
<div class="modal-body">
2222
<h3>Controller code <small class="pull-right">{{ controller_file_path }}</small></h3>
23-
<pre><code class="php">{{ controller_source_code|raw }}</code></pre>
23+
<pre><code class="php">{{ controller_source_code }}</code></pre>
2424

2525
<h3>Twig template code <small class="pull-right">{{ template_file_path }}</small></h3>
26-
<pre><code class="twig">{{ template_source_code|raw }}</code></pre>
26+
<pre><code class="twig">{{ template_source_code }}</code></pre>
2727
</div>
2828
</div>
2929
</div>

src/AppBundle/Twig/SourceCodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function showSourceCode(\Twig_Environment $twig, $template)
5050
return $twig->render('default/_source_code.html.twig', array(
5151
'controller_source_code' => $this->getControllerCode(),
5252
'controller_file_path' => $this->getControllerRelativePath(),
53-
'template_source_code' => htmlspecialchars($this->getTemplateCode(), ENT_QUOTES, 'UTF-8'),
53+
'template_source_code' => $this->getTemplateCode(),
5454
'template_file_path' => $this->getTemplateRelativePath(),
5555
));
5656
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy