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

@@ -360,7 +360,7 @@ class TestGraphics(BaseTest):
self.ae(img['data'], random_data)
# Test loading from file
f = tempfile.NamedTemporaryFile()
f = tempfile.NamedTemporaryFile(prefix='tty-graphics-protocol-')
f.write(random_data), f.flush()
sl(f.name, s=24, v=32, t='f', expecting_data=random_data)
self.assertTrue(os.path.exists(f.name))