Skip to content

Commit aa12dfa

Browse files
committed
fix the bug that makes it impossible to send images to other tabs
1 parent 39827a3 commit aa12dfa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/generation_parameters_copypaste.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import io
33
import os
44
import re
5+
from pathlib import Path
6+
57
import gradio as gr
68
from modules.shared import script_path
79
from modules import shared
@@ -35,9 +37,8 @@ def quote(text):
3537
def image_from_url_text(filedata):
3638
if type(filedata) == dict and filedata["is_file"]:
3739
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'
4142

4243
return Image.open(filename)
4344

0 commit comments

Comments
 (0)