File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 2
2
import io
3
3
import os
4
4
import re
5
+ from pathlib import Path
6
+
5
7
import gradio as gr
6
8
from modules .shared import script_path
7
9
from modules import shared
@@ -35,9 +37,8 @@ def quote(text):
35
37
def image_from_url_text (filedata ):
36
38
if type (filedata ) == dict and filedata ["is_file" ]:
37
39
filename = filedata ["name" ]
38
- tempdir = os .path .normpath (tempfile .gettempdir ())
39
- normfn = os .path .normpath (filename )
40
- assert normfn .startswith (tempdir ), 'trying to open image file not in temporary directory'
40
+ is_in_right_dir = any (Path (temp_dir ).resolve () in Path (filename ).resolve ().parents for temp_dir in shared .demo .temp_dirs )
41
+ assert is_in_right_dir , 'trying to open image file outside of allowed directories'
41
42
42
43
return Image .open (filename )
43
44
You can’t perform that action at this time.
0 commit comments