@@ -1256,8 +1256,9 @@ def _convert_psfrags(tmppath, psfrags, paper_width, paper_height, orientation):
12561256
12571257 with TemporaryDirectory () as tmpdir :
12581258 psfile = os .path .join (tmpdir , "tmp.ps" )
1259+ # -R1 is a security flag used to prevent shell command execution
12591260 cbook ._check_and_log_subprocess (
1260- ['dvips' , '-q' , '-R0 ' , '-o' , psfile , dvifile ], _log )
1261+ ['dvips' , '-q' , '-R1 ' , '-o' , psfile , dvifile ], _log )
12611262 shutil .move (psfile , tmppath )
12621263
12631264 # check if the dvips created a ps in landscape paper. Somehow,
@@ -1301,7 +1302,7 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
13011302
13021303 cbook ._check_and_log_subprocess (
13031304 [mpl ._get_executable_info ("gs" ).executable ,
1304- "-dBATCH" , "-dNOPAUSE" , "-r%d" % dpi , "-sDEVICE=ps2write" ,
1305+ "-dBATCH" , "-dNOPAUSE" , "-dSAFER" , "- r%d" % dpi , "-sDEVICE=ps2write" ,
13051306 * paper_option , f"-sOutputFile={ psfile } " , tmpfile ],
13061307 _log )
13071308
@@ -1345,6 +1346,7 @@ def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
13451346 # happy (https://ghostscript.com/doc/9.56.1/Use.htm#MS_Windows).
13461347 cbook ._check_and_log_subprocess (
13471348 ["ps2pdf" ,
1349+ "-dSAFER" ,
13481350 "-dAutoFilterColorImages#false" ,
13491351 "-dAutoFilterGrayImages#false" ,
13501352 "-sAutoRotatePages#None" ,
0 commit comments