@@ -282,7 +282,7 @@ public static function setGsPath($path = null)
282
282
throw new \InvalidArgumentException ('The given file is not executable ' );
283
283
}
284
284
285
- @exec ($ path . ' -v ' , $ result );
285
+ @exec (' " ' . $ path . '" -v ' , $ result );
286
286
$ content = implode ("\n" , $ result );
287
287
if (false === stripos ($ content , 'ghostscript ' )) {
288
288
throw new \InvalidArgumentException ('No valid Ghostscript found ' );
@@ -363,9 +363,10 @@ public function getInputFile()
363
363
*/
364
364
public function setOutputFile ($ name = 'output ' )
365
365
{
366
- if (0 !== strpos ($ name, DIRECTORY_SEPARATOR )) {
366
+ if ($ this -> isRelative ($ name )) {
367
367
$ name = $ this ->getBasePath () . DIRECTORY_SEPARATOR . $ name ;
368
368
}
369
+
369
370
$ this ->outfile = $ name ;
370
371
371
372
return $ this ;
@@ -382,7 +383,7 @@ public function setOutputFile($name = 'output')
382
383
*/
383
384
public function getOutputFile ()
384
385
{
385
- if (0 !== strpos ($ this ->outfile , DIRECTORY_SEPARATOR )) {
386
+ if ($ this -> isRelative ($ this ->outfile )) {
386
387
return $ this ->getBasePath () . DIRECTORY_SEPARATOR . $ this ->outfile ;
387
388
}
388
389
@@ -440,7 +441,7 @@ public function getRenderString()
440
441
if (null === $ this ->getInputFile ()) {
441
442
return '' ;
442
443
}
443
- $ string = self ::getGsPath ();
444
+ $ string = ' " ' . self ::getGsPath () . ' " ' ;
444
445
$ string .= ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH ' ;
445
446
$ string .= ' -sOutputFile=" ' . $ this ->getOutputFileName () . '" ' ;
446
447
$ string .= $ this ->getDevice ()->getParameterString ();
@@ -652,11 +653,11 @@ public function setUseCie($useCie = true)
652
653
return $ this ;
653
654
}
654
655
655
- /**
656
- * Shall we use the CIE map for color-conversions?
657
- *
658
- * @return boolean
659
- */
656
+ /**
657
+ * Shall we use the CIE map for color-conversions?
658
+ *
659
+ * @return boolean
660
+ */
660
661
public function useCie ()
661
662
{
662
663
return (bool ) $ this ->useCie ;
@@ -889,6 +890,19 @@ public function getOutputFileName()
889
890
890
891
return $ basename ;
891
892
}
893
+
894
+ private function isRelative ($ path )
895
+ {
896
+ if (0 === strpos ($ path , DIRECTORY_SEPARATOR )) {
897
+ return false ;
898
+ }
899
+
900
+ if (1 === strpos ($ path , ': \\' ) && preg_match ('/^[A-Za-z]/ ' , $ path )) {
901
+ return false ;
902
+ }
903
+
904
+ return true ;
905
+ }
892
906
}
893
907
894
908
try {
0 commit comments