diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-05-27 00:18:45 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-05-28 18:10:13 +0200 |
commit | 33321b43cafbb731bff062aeffd6f46e38749faf (patch) | |
tree | 201c2296022f015d686368537dde36ea7d7b1ab1 /application/libraries/Pygments.php | |
parent | d00027bbba30a7693135c8b7cb5de267e8c478d4 (diff) |
Improve running of external commands
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/libraries/Pygments.php')
-rw-r--r-- | application/libraries/Pygments.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/application/libraries/Pygments.php b/application/libraries/Pygments.php index 588f78842..5d37b69c3 100644 --- a/application/libraries/Pygments.php +++ b/application/libraries/Pygments.php @@ -22,11 +22,14 @@ class Pygments { private static function get_pygments_info() { return cache_function_full('pygments_info-v2', 1800, function() { - ob_start(); - passthru(escapeshellarg(FCPATH."scripts/get_lexer_list.py")); - $output = ob_get_clean(); + $r = (new \libraries\ProcRunner(array(FCPATH."scripts/get_lexer_list.py")))->execSafe(); - return json_decode($output, true); + $ret = json_decode($r["stdout"], true); + if ($ret === NULL) { + throw new \exceptions\ApiException('pygments/json-failed', "Failed to decode JSON", $r); + } + + return $ret; }); } |