diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php
index 79dd9938b6..5bc383d5f5 100644
--- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php
+++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php
@@ -134,7 +134,7 @@ class CodeExtension extends AbstractExtension
*/
public function fileExcerpt($file, $line, $srcContext = 3)
{
- if (is_readable($file)) {
+ if (is_file($file) && is_readable($file)) {
// highlight_file could throw warnings
// see https://bugs.php.net/bug.php?id=25725
$code = @highlight_file($file, true);
@@ -157,6 +157,8 @@ class CodeExtension extends AbstractExtension
return '
'.implode("\n", $lines).'
';
}
+
+ return null;
}
/**
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig
index f69406475a..747d73f5de 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig
@@ -54,6 +54,11 @@ a.doc:hover {
text-decoration: underline;
}
+.empty {
+ padding: 10px;
+ color: #555;
+}
+
.source {
margin-top: 41px;
}
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig
index 58e1fe3556..ba94bc0eff 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig
+++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.html.twig
@@ -7,11 +7,16 @@
{% endblock %}
{% block body %}
-
-
- {{ filename|file_excerpt(line, -1) }}
-
+ {% set source = filename|file_excerpt(line, -1) %}
+
+
+ {% if source is null %}
+
The file is not readable.
+ {% else %}
+ {{ source|raw }}
+ {% endif %}
+
{% endblock %}