@@ -45,12 +45,18 @@ public static function highlight($source, $language, $encoding = "utf-8", $forma
4545 2 => array ('pipe ' , 'w ' ), // stderr
4646 );
4747
48- if (!empty ($ language ))
49- $ args = sprintf (" -f %s -l %s -O encoding=%s,style=%s,lineos=1,startinline=true " , $ formatter , $ language , $ encoding , $ style );
50- else
51- $ args = sprintf (" -f %s -g -O encoding=%s,style=%s,lineos=1 " , $ formatter , $ encoding , $ style );
48+ $ args = array (
49+ '-f ' . escapeshellarg ($ formatter )
50+ );
51+ if (!empty ($ language )) {
52+ $ args [] = '-l ' . escapeshellarg ($ language );
53+ $ args [] = '-O ' . escapeshellarg (sprintf ('encoding=%s,style=%s,lineos=1,startinline=true ' , $ encoding , $ style ));
54+ } else {
55+ $ args [] = '-g ' ;
56+ $ args [] = '-O ' . escapeshellarg (sprintf ('encoding=%s,style=%s,lineos=1 ' , $ encoding , $ style ));
57+ }
5258
53- $ proc = proc_open (self ::PIGMENTS_BINARY .$ args , $ dspec , $ pipes );
59+ $ proc = proc_open (self ::PIGMENTS_BINARY .' ' . implode ( ' ' , $ args) , $ dspec , $ pipes );
5460
5561 if (is_resource ($ proc )) {
5662 // Reads the stdout output.
@@ -84,4 +90,4 @@ public static function highlight($source, $language, $encoding = "utf-8", $forma
8490
8591 }
8692
87- }
93+ }
0 commit comments