Graphics protocol: Only delete temp files if they have the string tty-graphics-protocol in their file paths.

This prevents deletion of arbitrary files in /tmp via the graphics
protocol.
This commit is contained in:
Kovid Goyal
2022-08-16 11:19:32 +05:30
parent ca2a121696
commit d0c50248ea
6 changed files with 12 additions and 8 deletions

View File

@@ -301,7 +301,7 @@ def render_as_single_image(
remove_alpha: str = '', flip: bool = False, flop: bool = False,
) -> Tuple[str, int, int]:
import tempfile
fd, output = tempfile.mkstemp(prefix='icat-', suffix=f'.{m.mode}', dir=tdir)
fd, output = tempfile.mkstemp(prefix='tty-graphics-protocol-', suffix=f'.{m.mode}', dir=tdir)
os.close(fd)
result = render_image(
path, output, m, available_width, available_height, scale_up,