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