8000 [FrameworkBundle] Added a check on file mime type for CodeHelper::fil… · symfony/symfony@773d818 · GitHub
[go: up one dir, main page]

Skip to content

Commit 773d818

Browse files
author
Francis Besset
committed
[FrameworkBundle] Added a check on file mime type for CodeHelper::fileExcerpt()
1 parent af7f75f commit 773d818

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ public function formatArgs(array $args)
143143
public function fileExcerpt($file, $line)
144144
{
145145
if (is_readable($file)) {
146+
if (extension_loaded('fileinfo')) {
147+
$finfo = new \Finfo();
148+
if ('application/octet-stream' === $finfo->file($file, FILEINFO_MIME_TYPE)) {
149+
return;
150+
}
151+
}
152+
146153
$code = highlight_file($file, true);
147154
// remove main code/span tags
148155
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);

0 commit comments

Comments
 (0)
0