From b12d7cb03ab1ef63baab4a8d4b1380e6990c1437 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 7 Oct 2012 12:11:24 +0200 Subject: c/file/download: display an error if highlighting fails Previously we displayed an empty page since stderr usually goes to the error log of the web server. Signed-off-by: Florian Pritz --- application/controllers/file.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/application/controllers/file.php b/application/controllers/file.php index 752d796cc..9616c0fc6 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -169,24 +169,28 @@ class File extends CI_Controller { ob_start(); if ($mode == "rmd") { echo ''."\n"; - passthru('perl '.FCPATH.'scripts/Markdown.pl '.escapeshellarg($file)); + passthru('perl '.FCPATH.'scripts/Markdown.pl '.escapeshellarg($file), $return_value); } elseif ($mode == "ascii") { echo '
'."\n";
-				passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file));
+				passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $return_value);
 				echo "
\n"; } else { echo '
';
 				// generate line numbers (links)
-				passthru('perl -ne \'print "$.\n"\' '.escapeshellarg($file));
+				passthru('perl -ne \'print "$.\n"\' '.escapeshellarg($file), $return_value);
 				echo '
'."\n"; - passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8 -l '.escapeshellarg($mode).' -f html '.escapeshellarg($file)); + passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8 -l '.escapeshellarg($mode).' -f html '.escapeshellarg($file), $return_value); } $cached = ob_get_contents(); ob_end_clean(); $this->memcachelibrary->set($filedata['hash'].'_'.$mode, $cached, 100); } - $this->output->append_output($cached); + if ($return_value != 0) { + show_error("Error trying to process the file. Either the lexer is unknown or something is broken.\n"); + } else { + $this->output->append_output($cached); + } $this->load->view($this->var->view_dir.'/html_footer', $this->data); } -- cgit v1.2.3-24-g4f1b